From the global perspective of the application, if only one instance of the class can be generated, you can consider the singleton mode.
□Real-time loading Singleton Mode
Assign a class instance to a static field of the class.
class Program { static void Main(string[] args) { Logger log = Logger.GetInstance(); log.WriteToFile(); Console.Read(); } } public class
Module1, module definition : Used to logically organize Python code to achieve a specific function, essentially a. py end of the Python file.2, the module import method :Suppose there are 2 modules module_01 and module_02, with the following code:1 #module_01 Module2Module_name ="module_01"3 defSayhi (call_name):4 Print("executed in module_01, called by%s"%call_name)5 deflogger ():6 Print("logger in the%s"% module_name)1 #module_02 Module2Modu
4. Configuration
Inserting log requests into the application code requires a lot of pre-planning and final efforts. It is shown that about 4% of the code is used for output.
Therefore, programs of moderate size are embedded with thousands of log output statements. To manage the output status of these logs in a way that does not require manual management, it is imperative to number and standardize the log output.
Log4j is fully configurable in the program. However, using the configuration file t
Detailed description of Python self-built logging module and python self-built logging Module
Easy to use
At first, we used the shortest code to experience the basic functions of logging.
Import logginglogger = logging. getLogger () logging. basicConfig () logger. setLevel ('debug') logger. DEBUG ('logsomething ') # output out> DEBG: root: logsomething
Step 1: Use the logging. getLogger function to obtain a
standard output and only displays logs that are greater than or equal to the warning level, indicating that the default logging level is set to warning (log level level critical > ERROR > WARNING > INFO > DEBUG > NOTSET), the default log format is log level: Logger name ( the default logger name is root): User output message.We can customize the output log format, location, and level through the Basicconfi
standard output and only displays logs that are greater than or equal to the warning level, indicating that the default logging level is set to warning (log level level critical > ERROR > WARNING > INFO > DEBUG > NOTSET), the default log format is log level: Logger name ( the default logger name is root): User output message.We can customize the output log format, location, and level through the Basicconfi
first, the level of LoggerMore detailed than the log4j level, all defined in Java.util.logging.Level.The levels are sorted in descending order as Follows:SEVERE (highest Value)WARNINGINFOCONFIGFINEFinerFINEST (lowest Value)In addition, there is a level off that can be used to turn off logging and use level all to enable logging for all Messages.Logger The default level is info, and logs that are lower than info will not be displayed (but also written to the file).Attention:High-level
Document directory
Use the Registry
Use reflection
Encapsulate the Registry
Classloaders
Serialization
Singleton mode conclusion
Use the Registry
You can use a singleton registry:
In running period refers to order EXAMPLE Class
Prevents instances that generate multiple Singleton subclass classesIn the singleton class in Example 8, a registration registry for Singleton classes is maintained:Example 8 Singleton class with registry
ImportJava. util.Hashmap;
ImportOrg. Apache. log4j.
Request for baidu:
Because no form information is input, the message body of the request is empty. You can try it on the login page.
First come here, the knowledge of the HTTP protocol is very rich on the internet, and I will not discuss it here.
Ii. Three implementations of File Upload
1. Jsp/servlet File Upload
This is the most common and simplest method.
(1) Jsp page for File Upload
(2) FileUploadServlet
Import java. io. file; import java. io. fileOutputStream; import java. io. IOExce
20155336 2016-2017-2 "Java program design" Eighth Week study summary textbook study summary14th Chapter NIO and NIO2
About NIONIO使用频道来衔接数据结点,在处理数据时,NIO可以让你设定缓冲区容量,在缓冲区中对感兴趣的数据区块进行标记,像是标记读取位置、数据有效位置,对于这些区块标记,提供了Clear()、rewind()、flip()、compact()等高级操作。
NIO2 IntroductionNIO2文件系统API提供一组标准接口与类,应用程序开发者只要基于这些标准接口与类进行文件系统操作,底层实际如何进行文件系统操作,是由文件系统提供负责。
15th General API
Log
Features: The
java.util.logging Package provides a log function related class and interface IOU
What the log is. It is not just a bunch of System.out.println (). Remember that when you first learn Java, you will not debug, so you use System.out.println () to print the value of the variable in a critical position. Once you have the log program, it is essentially the same, and you have to manually invoke the log program's API where you need it, such as the Common Log.info (). But the advantage of using the log program is that the output is formatted, is more standardized, and can be easily i
in the unzipped src directory, and you can get log4net.dll after compiling. The user wants to add the log function in own program, only then can the Log4net.dll introduce the project.
2 log4net The Structure
Log4net has four main components, namely Logger (recorder), Repository (library), Appender (attachment) and Layout (layout).
2.1 Logger
2.1.1 Logger Interf
1. Logger class
Use the static logger method logger. getrootlogger of the logger class to obtain the rootlogger. All other loggers are instantiated and obtained through the static method logger. getlogger. In this method, logger
Command sent by flash to the server; otherwise, the server cannot receive the message (my server is developed in Java)
// ================================================ =;//Server code(I useJavaDeveloped by others);// Chatserver. Java// ================================================ =;Package com. klstudio. Socket. Chat;Import java. Io. ioexception;Import java.net. serversocket;Import java.net. Socket;Import java. util. vector;// Import com. klstudio. util.
.
LevelRangeFilter
Events with a log level within a specified range are recorded.
LoggerMatchFilter
Logger name match.
PropertyFilter
The message is recorded only when it matches the specified property value.
StringMathFilter
The specified string is matched by the message.
3. Layouts
It is used to control the output format of Appender, which can be linear or Xml. however, one Appender can have onl
the file as a rollback File
SmtpAppender
Write logs to emails
2. Filters
The filter can filter out the content output by Appender.
DenyAllFilter
Prevent all log events from being recorded
LevelMatchFilter
Only log events of the specified level are recorded.
LevelRangeFilter
Events with a log level within a specified range are recorded.
LoggerMatchFilter
Logger name match.
Pro
private boolean acc_shouzhi; // access private Integer acc_type; // category private String acc_beizhu; // remarks // getters and setters
Package com. springMvc. dao. entity; public class Type {private Integer type_id; // database IDprivate String type_name; // Type description private Integer type_parent; // parent class ID getters and settersThen there is the Manager. Here we will write a simple account Manager and write two
Package com. springMvc. dao. manager; import org. apache. log4j.
log4j, you can see the log4j FAQ to learn: What is the features of log4j? 2. Three elements of log4jlog4j There are 3 important concepts: loggers, appenders and layouts, these 3 elements enable developers to introduce log4j libraries to flexibly control print behavior, such as log levels, in-loglog format and print destination (such as local or remote printing), and so on.2.1 Loggersin fact, loggers are some case-sensitive named entities that are named following a hierarchical naming convention
messages into a directory as files, and SMTP agents like IIS SMTP agent can read or send them.
The TelnetAppender client accepts log events via Telnet.
TraceAppender writes the log to the .NET trace system.
UdpAppender sends the log to the remote host as a connectionless UDP datagram or broadcasts as a UdpClient.
2.2 Filters
Filters can be used to filter out the contents of the Appender output. Filters usually have the following types:
DenyAllFilter prevents all log events from
Part of the reference to the blog.
Http://www.cppblog.com/tx7do/articles/11719.html
Filter log information based on script configurationIn addition to the configuration of the log environment through the program, Log4cplus implements the scripting-based functionality through the Propertyconfigurator class. PassThe script can complete the configuration of logger, appender and layout, so it can solve the problem of how to output and where to go, I will
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.