Log4j. propertie configuration details

Source: Internet
Author: User

1. log4j. rootcategory = info, stdout, R

This sentence outputs the log information with the info level to the stdout and R destinations. The stdout and R definitions can be named in the following code. Levels can be divided into off, fatal, error, warn, info, debug, and all. If off is configured, no information is displayed. If Info is configured, only info, warn is displayed, but the debug information is not displayed.


2. log4j. appender. stdout = org. Apache. log4j. leleappender

Define the output end type named stdout, which can be

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)


3. log4j. appender. stdout. layout = org. Apache. log4j. patternlayout

This sentence defines the layout type at the output end of stdout, which can be

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)


4. log4j. appender. stdout. layout. conversionpattern = [%-5 p] % d {yyyy-mm-dd hh: mm: SS, SSS} method: % L % N % m % N

If you use the pattern layout, you must specify the specific format of the print information conversionpattern. The print parameters are as follows:

% M output the specified message in the code

% P output priority, namely debug, info, warn, error, fatal

% R the number of milliseconds it takes to output the log information from application startup to output

% C output category, usually the full name of the class

% T name of the thread that outputs the log event

% N output a carriage return line break. For Windows, the value is "RN", and for UNIX, the value is "N"

% D date or time of the log output time point. The default format is iso8601. You can also specify the format after it, for example, % d {yyyy Mmm dd hh: mm: SS, SSS}, output is similar to: October 18, 2002 22:10:28, 921

% L location of log event output, including category name, thread, and number of lines in the code


5. log4j. appender. r = org. Apache. log4j. dailyrollingfileappender

This sentence is the same as that of row 3rd. Define the output type named R to generate a log file every day.


6. log4j. appender. R. File = D: \ Tomcat 5.5 \ logs \ QC. Log

This sentence defines the output end file named R as D: \ Tomcat 5.5 \ logs \ QC. log, which can be modified by yourself.


7. log4j.logger.com. Neusoft = debug

Specify the levels of all classes under the com. Neusoft package as debug.

You can change com. Neusoft to the package name used by your project.


8. log4j. appender. R. Threshold = infoSpecify the minimum output level of log messages.


9. log4j. appender. R. maxfilesize = 10 MB

When the log file reaches this hour, it will automatically scroll, moving the original content to the QC. Log File


10. log4j. appender. R. maxbackupindex = 10

Specifies the maximum number of rolling files that can be generated.


11. log4j. appender. datalog. Encoding = UTF-8

Encoding format of log output

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.