Log4j configuration file basic meaning description

xiaoxiao2021-03-06  37

Log4j.properties profile explains the following:

# Set root logger level to debug and its only appender to a1

# log4j has five Logger

#Fatal 0

#Error 3

#Warn 4

#Info 6

#Debug 7

Configure root Logger, whose syntax is:

# log4j.rootlogger = [level], appendername, appendername, ...

Log4j.rootlogger = info, a1, r

# This sentence is set to have all logs output

# If log4j.rootlogger = warn, it means that only Warn, Error, Fatal

# Output, Debug, INFO will be blocked.

# A1 is set to be a consoleapplender.

# log4j Appender has several layers such as console, file, GUI components, and even set interface servers, NT event logger, UNIX Syslog daemon, etc.

#ConsoleAppender output to the console

Log4j.Appender.a1 = org.apache.log4j.consoleAppender

# A1 The output layout used, where log4j provides four layouts. Org.apache.log4j.htmlLayout (layout in HTML table)

# org.apache.log4j.patternlayout (can be flexibly specified for layout mode),

# org.apache.log4j.simplelayout (level and information string with log information),

# org.apache.log4j.ttccLayout (including information, thread, category, etc.)

Log4j.Appender.a1.Layout = org.apache.log4j.patternLayout # flexible definition output format Specific View log4j javadoc org.apache.log4j.patternlayout #d time .... log4j.appender.a1.Layout.conversionPattern =% - D {YYYY-MM-DD HH: mm: SS} [% C] - [% P]% M% N #R Output to the file ROLLINGFILEAPPENDER extension, you can provide a backup function of a log. Log4j.Appender.r = org.apache.log4j.rollingfileaplender # log file name log4j.Appender.r.file = log4j.log # log file size log4j.Appender.r.maxFileSize = 100kb # Save a backup file log4j. appender.r.maxbackupindex = 1 log4j.appender.r.Layout = org.apache.log4j.tccLayout # log4j.Appender.r.Layout.conversionPattern =% - D {yyyy-mm-dd hh: mm: ss} [% C] - [% P]% M% N

Configure root Logger, whose syntax is:

Log4j.rootlogger = [level], appendername, appendername, ...

Level is the priority of logging

Appendername is where the specified log information is output to which place. You can specify multiple output destinations at the same time.

Configure the log information output Destination Appender, its syntax is

Log4j.Appender.Appendername = full.qualified.name.of.Appender.classlog4j.Appender.Appendername.Option1 = Value1

...

Log4j.appender.Appendername.Option = VALUEN

The Appender provided by log4j has the following:

Org.apache.log4j.consoleappender (console),

Org.apache.log4j.fileappender (file),

Org.apache.log4j.dailyrollingFileAppender (a log file is generated),

Org.apache.log4j.rollingfileAppender generated a new file when the file is reached to specify the size,

Org.apache.log4j.writerappender (send log information to any specified place in stream format)

Configure the format (layout) of log information, whose syntax is:

Log4j.Appender.Appendername.Layout = Fully.qualified.Name.Of.Layout.class

Log4j.Appender.Appendername.Layout.Option1 = Value1

....

Log4j.Appender.Appendername.Layout.Option = VALUEN

Layout provided by LOG4J has the following: org.apache.log4j.htmllayout (layout in HTML form),

Org.apache.log4j.patternlayout (you can flexibly designate the layout mode),

Org.apache.log4j.simplelayout (level and information string with log information),

Org.apache.log4j.ttccLayout (including information, thread, category, etc.)

转载请注明原文地址:https://www.9cbs.com/read-57179.html

New Post(0)