Parameters |
Description |
Example |
%c |
Lists the full name of the logger namespace, if the {< layer is added, the namespace that lists the specified number of layers from the most inner layer |
log4j configuration File Parameters Example |
Output Display Media |
Suppose the current logger namespace is "A.B.C" |
%c |
A.b.c |
%C{2} |
B.c |
%20c |
(If the namespace length is less than 20, the left is padded with spaces) |
%-20c |
(If the namespace length is less than 20, the right side is padded with spaces) |
%.30c |
(If the namespace is longer than 30, the extra characters are truncated) |
%20.30c |
(If the namespace length is less than 20, the left is padded with spaces; If the namespace is longer than 30, the extra characters are truncated) |
%-20.30c |
(If the namespace length is less than 20, the right side is filled with spaces; If the namespace is longer than 30, the extra characters are truncated) |
%c |
Lists the full name of the class that called logger (contains the package path) |
Assuming the current class is "Org.apache.xyz.SomeClass" |
%c |
Org.apache.xyz.SomeClass |
%c{1} |
SomeClass |
%d |
Displays the logging time,{< date format;} Use 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} |
OCT 2005 22:23:30,117 |
%d{iso8601} |
2005-10-12 22:23:30,117 |
%F |
Displays the source file name of the call logger |
%F |
Myclass.java |
%l |
Where the output log event occurs, including the class name, the thread that occurred, and the number of rows in the code |
%l |
Myclass.main (myclass.java:129) |
%l |
Shows the line of code that called logger |
%l |
129 |
%m |
Show output message |
%m |
A message for Debug. |
%M |
Shows the name of the method that called logger |
%M |
Main |
%n |
Line breaks under the current platform |
%n |
The RN is represented under Windows platform The Unix platform represents N |
%p |
Show priority for this log |
%p |
INFO |
%r |
Displays the number of milliseconds that have elapsed since the start of the program to record the log |
%r |
1215 |
%t |
Output the name of the thread that generated the log event |
%t |
MyClass |
%x |
Output logs in order by NDC (Nested Diagnostic Context, thread stack) |
Assume that a program call order is MyApp call Com.foo.Bar |
%c%x-%m%n |
Myapp-call Com.foo.Bar. Com.foo.bar-log in Bar Myapp-return to MYAPP. |
%x |
Press the MDC (Mapped Diagnostic Context, Thread mapping table) to output the log. Typically used for multiple clients to connect to the same server, which makes it easier for the server to differentiate between the logs that client access leaves behind. |
%X{5} |
(Log of the client logged with the code number 5) |
%% |
Display a percent semicolon |
%% |
%
|