log4j output format notes ----

Illustrative examples of the number of

%c
Full name listed logger namespace, if coupled with {<levels> List} represents the specified number counted from the innermost layer of the namespace
Example log4j profile parameters
The output shows media
Suppose the current logger namespace is "abc"
%c a.b.c
%c{2} b.c
%20c (If the namespace length is less than 20, then padded with spaces left)
%-20c (If the namespace length is less than 20, then to the right with spaces)
% .30c (If the name is longer than 30 space, cut off the excess characters)
% 20.30c (If the namespace length is less than 20, then padded with spaces on the left; if the name space is longer than 30, cut off the excess characters)
% -20.30c (If the namespace length is less than 20, then padded with spaces to the right; if the name space is longer than 30, cut off the excess characters)
%C
It lists the full name (including the package path) call logger class Suppose the current class is "org.apache.xyz.SomeClass"
%C org.apache.xyz.SomeClass
%C{1} SomeClass
%d
Display the log recording time, {<date format>} using the date format defined by ISO8601 %d{yyyy/MM/dd HH:mm:ss,SSS} 2005/10/12 22:23:30,117
%d{ABSOLUTE} 22:23:30,117
%d{DATE} 12 Oct 2005 22:23:30,117
%d{ISO8601} 2005-10-12 22:23:30,117
%F
Call logger displays the source file name %F MyClass.java
%l
The occurrence location of the output log events, including the categories were the threads, as well as the number of lines in the code %l MyClass.main(MyClass.java:129)
%L
Call logger display lines of code %L 129
%m
It outputs a message %m This is a message for debug.
%M
显示调用logger的方法名 %M main
%n
当前平台下的换行符 %n Windows平台下表示rn
UNIX平台下表示n
%p
显示该条日志的优先级 %p INFO
%r
显示从程序启动时到记录该条日志时已经经过的毫秒数 %r 1215
%t
输出产生该日志事件的线程名 %t MyClass
%x
按NDC(Nested Diagnostic Context,线程堆栈)顺序输出日志 假设某程序调用顺序是MyApp调用com.foo.Bar
%c %x - %m%n MyApp - Call com.foo.Bar.
com.foo.Bar - Log in Bar
MyApp - Return to MyApp.
%X
按MDC(Mapped Diagnostic Context,线程映射表)输出日志。通常用于多个客户端连接同一台服务器,方便服务器区分是那个客户端访问留下来的日志。 %X{5} (记录代号为5的客户端的日志)
%%
显示一个百分号 %% %

 

 -----转https://avaj.iteye.com/blog/246088

 

Guess you like

Origin www.cnblogs.com/tk55/p/11095844.html