Log4j-configuration file

Source: Internet
Author: User

The log4j. properties configuration file is described as follows:

# Set root logger level to debug and its only appender to A1
# Log4j has five levels of logger
# Fatal 0
# Error 3
# Warn 4
# INFO 6
# Debug 7 Configure the root logger with the Syntax:
# Log4j. rootlogger = [level], appendername, appendername ,...
Log4j. rootlogger = info, A1, R
# This sentence indicates that all logs are output.
# If it is log4j. rootlogger = warn, it means only warn, error, fatal
# Output. debug and info will be blocked.
# A1 is set to be a consoleappender.
# The appender in log4j has several layers, such as the console, files, Gui components, and even an interface server, NT event recorder, and Unix Syslog daemon.
# Leleappender output to the console
Log4j. appender. A1 = org. Apache. log4j. leleappender
# Output layout used by a1. log4j provides four layout S: org. Apache. log4j. htmllayout (layout in HTML form)
# Org. Apache. log4j. patternlayout (you can flexibly specify the layout mode ),
# Org. Apache. log4j. simplelayout (including the log information level and information string ),
# Org. Apache. log4j. ttcclayout (including the log generation time, thread, category, and other information)

Log4j. appender. a1.layout = org. Apache. log4j. patternlayout
# Flexibly define the output format. For details, see 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 extension output to file rollingfileappender, which can provide a log backup function.
Log4j. appender. r = org. Apache. log4j. rollingfileappender
# Log File Name
Log4j. appender. R. File = log4j. Log
# Log File Size
Log4j. appender. R. maxfilesize = 100kb
# Saving a backup file
Log4j. appender. R. maxbackupindex = 1 log4j. appender. R. layout = org. Apache. log4j. ttcclayout
# Log4j. appender. R. layout. conversionpattern = %-d {yyyy-mm-dd hh: mm: SS} [% C]-[% P] % m % N

Configure the root logger with the Syntax:

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

Level is the log record priority.
Appendername specifies where the log information is output. You can specify multiple output destinations at the same time.

 

Configure the appender of the log output destination. Its syntax is

Log4j. appender. appendername = fully. Qualified. Name. Of. appender. Class
Log4j. appender. appendername. option1 = value1
...
Log4j. appender. appendername. Option = valuen

Log4j provides the following types of appender:
Org. Apache. log4j. leleappender (console ),
Org. Apache. log4j. fileappender (file ),
Org. Apache. log4j. dailyrollingfileappender (a log file is generated every day ),
Org. Apache. log4j. rollingfileappender (a new file is generated when the file size reaches the specified size ),
Org. Apache. log4j. writerappender (send log information to any specified place in stream format)

 

Configure the log information format (layout). Its syntax is:

Log4j. appender. appendername. layout = fully. Qualified. Name. Of. layout. Class
Log4j. appender. appendername. layout. option1 = value1
....
Log4j. appender. appendername. layout. Option = valuen

Log4j provides the following layout types:
Org. Apache. log4j. htmllayout (in the form of HTML tables ),
Org. Apache. log4j. patternlayout (you can flexibly specify the layout mode ),
Org. Apache. log4j. simplelayout (including the log information level and information string ),
Org. Apache. log4j. ttcclayout (including the log generation time, thread, category, and so on)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.