log4j.rootLogger=INFO,all_log,err_log,Console
(Overall log output)
#interface#
log4j.logger.com.zzxdev.qyd.controller.orderInterface.OrderInterfaceController=INFO,order
log4j.appender.order.Encoding=UTF-8
log4j.appender.order=org.apache.log4j.DailyRollingFileAppender
(DailyRollingFileAppender: Generates a log file every day)
log4j.appender.order.layout=org.apache.log4j.PatternLayout
(PatternLayout: Flexibility to specify layout patterns)
#log4j.appender.order.layout.ConversionPattern=%m%n
log4j.appender.order.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss SSS} %-5p [%t]
%C{1}.%M(%L) – %m%n
ConversionPattern=%m%n: Sets the display log format
%p: indicates the priority of the output log information, including DEBUG, INFO, WARN, ERROR, and FATAL.
%d: indicates the date or time of the log output time. The default format is ISO8601, or a later format can be specified, for example:
% d {yyyy/MM/dd HH: MM: ss, SSS}.
%r: Indicates the number of milliseconds elapsed between the start of the application and the output of this log message.
%t: outputs the name of the thread that generated the log event.
%L: the location of the output log event, equivalent to % C. %M(%F:%L), including the full name of the class, method, file name, and generation
The number of lines in the code. For example, test.testlog4j. main(testlog4j.java :10).
%c: Indicates the class to which the output log information belongs, usually the full name of the class.
%M: indicates the name of the method that generates logs.
%F: indicates the name of the file where the output log message is generated.
%L: : Line number in output code.
%m: : Prints the specific log information specified in the code.
%n: Outputs a carriage return newline character, “RN” on Windows or “n” on Unix.
%x: Outputs the NDC(nested diagnostic environment) associated with the current thread, especially in multi-client, multi-threaded applications such as Java Servlets.
%% : Outputs a “%” character.
In addition, you can place modifiers between % and format characters to control the minimum length, maximum length, and alignment of text. Such as:
1) c: Specifies the name of the output category. The minimum length is 20. If the category name length is less than 20, right-align by default.
2)% -20C: “-” indicates left alignment.
3)%.30c: Specifies the name of the output category. The maximum length of the category name is 30. If the category name is larger than 30, the extra characters will be truncated, but if the category name is smaller than 30, no Spaces will be added.
log4j.appender.order.DatePattern=’.’yyyy-MM-dd.HH
(Name of logs generated daily)
log4j.appender.order.file=/log/light/order/orderInterface.log
(Log file path)
log4j.appender.order.MaxFileSize=10MB
log4j.appender.order.MaxBackupIndex=1000
(Maximum number of log files)