Some of the commonly used log4j configuration properties are described

Source: Internet
Author: User
Tags log4j

1.ConsoleAppender Options
Threshold=warn: Specifies the lowest level of output for log messages.
Immediateflush=true: The default value is true, meaning that all messages will be immediately exported.
Target=system.err: By default: System.out, specify output console
2.FileAppender Options
Threshold=warn: Specifies the lowest level of output for log messages.
Immediateflush=true: The default value is true, meaning that all messages will be immediately exported.
File=mylog.txt: Specifies the message output to the Mylog.txt file.
Append=false: The default value is True, the message is incremented to the specified file, and false refers to overwriting the specified file contents with the message.
3.RollingFileAppender Options
Threshold=warn: Specifies the lowest level of output for log messages.
Immediateflush=true: The default value is true, meaning that all messages will be immediately exported.
File=mylog.txt: Specifies the message output to the Mylog.txt file.
Append=false: The default value is True, the message is incremented to the specified file, and false refers to overwriting the specified file contents with the message.
MAXFILESIZE=100KB: The suffix can be kb, MB, or GB. When the log file reaches that size, it scrolls automatically, moving the original content to the Mylog.log.1 file.
maxbackupindex=2: Specifies the maximum number of scrolling files that can be produced.
4.DailyRollingFileAppender Options
Threshold=warn: Specifies the lowest level of output for log messages.
Immediateflush=true: The default value is true, meaning that all messages will be immediately exported.
File=mylog.txt: Specifies the message output to the Mylog.txt file.
Append=false: The default value is True, the message is incremented to the specified file, and false refers to overwriting the specified file contents with the message.
Datepattern= '. ' YYYY-WW: Scrolls the file once a week, that is, a new file is generated each week. Of course, you can specify the month, week, day, time, and minutes. The corresponding format is as follows:
1) '. ' YYYY-MM: Monthly
2) '. ' YYYY-WW: Weekly
3) '. ' YYYY-MM-DD: Every day
4) '. ' Yyyy-mm-dd-a: two times a day
5) '. ' YYYY-MM-DD-HH: Per hour
6) '. ' YYYY-MM-DD-HH-MM: Per minute
5.PatternLayout Options
conversionpattern=%m%n: Specifies how to format the specified message.
6.HTMLLayout Options
Locationinfo=true: Default value is false, output Java file name and line number
Title=my app File: The default value is log4j Log Messages.
7.XMLLayout Options
Locationinfo=true: Default value is false, output Java file and line number

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.