Logback Common Configuration (ii)

Source: Internet
Author: User
Tags parent directory

http://blog.csdn.net/haidage/article/details/6794529


logback Common Configuration (ii) <appender>

">

<appender>:

<appender> is the child node of <configuration>, the component responsible for writing the log.

<appender> has two required attribute name and class. Name Specifies the Appender name, and class specifies the fully qualified name of the Appender.

1.ConsoleAppender:

Add the log to the console with the following child nodes:

<ENCODER>: Format the log. (Specific parameters will be explained later)

<target>: String System.out or System.err, default System.out;

For example: XML code<Configuration> <AppenderName= "STDOUT" class= "Ch.qos.logback.core.ConsoleAppender"><Encoder>< Pattern>%-4relative [%thread]%-5level%logger{35}-%msg%n</ Pattern></Encoder></Appender><RootLevel= "DEBUG"><Appender-refref= "STDOUT"/></Root></Configuration>

2.FileAppender:

Add the log to the file with the following child nodes:

<file>: The file name that is written, can be a relative directory, or it can be an absolute directory, and will be created automatically if the parent directory does not exist, and there is no default value.

<append>: If true, the log is appended to the end of the file, and if it is false, empty the existing file, the default is true.

<ENCODER>: Format the logged events. (Specific parameters will be explained later)

<prudent>: If true, the log is securely written to the file, even though other fileappender are also writing to the file, inefficient and false by default.

For example: XML code<Configuration><AppenderName= "FILE" class= "Ch.qos.logback.core.FileAppender"><file>TestFile.log</file> <Append>True</Append><Encoder>< Pattern>%-4relative [%thread]%-5level%logger{35}-%msg%n</ Pattern></Encoder></Appender><RootLevel= "DEBUG"><Appender-refref= "FILE"/></Root></Configuration>


3.RollingFileAppender:

Scrolls the record file, logs the log to the specified file, and records the log to other files when a condition is met. Has the following child nodes:

<file>: The file name that is written, can be a relative directory, or it can be an absolute directory, and will be created automatically if the parent directory does not exist, and there is no default value.

<append>: If true, the log is appended to the end of the file, and if it is false, empty the existing file, the default is true.

<ENCODER>: Format the logged events. (Specific parameters will be explained later)

<rollingpolicy>: When scrolling occurs, the behavior of the Rollingfileappender is determined, involving file movement and renaming.

<triggeringpolicy : tell rollingfileappender appropriate activation scrolling.

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.