Log4J log output format description

In the LOG4J configuration file, the log output format can be configured in the log4j.appender.CATNAME.layout.ConversionPattern item. The meaning of the format character is as follows.

 

Java code
  1. %n - newline  
  2. %m - log content     
  3. %p - log level (FATAL, ERROR, WARN, INFO, DEBUG or custom)      
  4. %r - milliseconds since the program started   
  5. %% - percent   sign   in   output  
  6. %t - the current thread name  
  7. %d - date and time,   
  8.     Commonly used formats are %d{DATE}, %d{ABSOLUTE}, %d{HH:mm:ss,SSS}, %d{ddMMyyyy HH:mm:ss,SSS}. . .  
  9. %l - same as %F%L%C%M  
  10.     %F - java source file name  
  11. %L - java source line number  
  12.     %C - java class name, %C{1} outputs the last element  
  13.     %M-java method name  
	%n - newline
	%m - log content   
	%p - log level (FATAL, ERROR, WARN, INFO, DEBUG or custom)    
	%r - milliseconds since the program started
	%% - percent   sign   in   output
	%t - the current thread name
	%d - date and time,
		Commonly used formats are %d{DATE}, %d{ABSOLUTE}, %d{HH:mm:ss,SSS}, %d{ddMMyyyy HH:mm:ss,SSS}. . .
	%l - same as %F%L%C%M
		%F - java source file name
	%L - java source line number
		%C - java class name, %C{1} outputs the last element
		%M-java method name

 

Example:

 

Java code
  1. [%d{HH\:mm\:ss\:SSS}][%p] (%c\:%L) - %m%n  
[%d{HH\:mm\:ss\:SSS}][%p] (%c\:%L) - %m%n
The output format is: [08:58:59:412][INFO] (com.soon.action:35) - server started

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326419943&siteId=291194637