How to style java content in the log file configuration

Character explanation:

% p: output log information indicating the priority, i.e. DEBUG, INFO, WARN, ERROR, FATAL, there may% and intermediate p - and figures, wherein - the number representing a left-aligned, numeral 5 represents the maximum excess of the position with a space padded
% d: output log date or time point in time, the default format is ISO8601, you can specify the format Thereafter, as:% d {yyyy / mM / dd HH: mm: ss, SSS}.
% r: output from the application to the number of milliseconds spent output the log information.
% t: output generated thread name of the log event.
% l: log event occurrence location output corresponds% c% M.: composition (% F% L), including the full name of the class, method, file name and line number in the code. For example: test.TestLog4j.main (TestLog4j.java:10).
Full name category output log information belongs, usually the class where:% c.
% M: generating log information output method name.
% F: output file name where the log messages generated.
% L :: outputs row number code.
% m :: specified output code specific log information.
% n: a carriage return line feed output, Windows platform "rn", Unix platform "n".
% x: output associated with the current thread and NDC (nested diagnostic context), especially in applications like java servlets used in this multi-client multi-threaded.
%%: output a "%" character.

test:

1, [% - 5p] [ % d {yyyy-MM-dd HH: mm: ss}]% c% L% m% n
A: Results are output in real environment:
[FATAL] [2020-03-02 17:48:02] com.bjpowernode.test.MyTest 9 fatal information
[eRROR] [2020-03-02 17:48:02] com.bjpowernode.test.MyTest 10 error information
[WARN] [2020-03-02 17:48:02] com.bjpowernode.test.MyTest 11 warn information
[iNFO] [2020-03-02 17:48:02] com.bjpowernode.test.MyTest 12 info information
interpreted in accordance with the above characters can you know what meaning

Published 144 original articles · won praise 3 · Views 4454

Guess you like

Origin blog.csdn.net/qq_42449963/article/details/104617356