Log4j Append property specifies whether to append content

Source: Internet
Author: User

log4j default is to keep the log content appended to the log file;

Here is a property Append default is true;

If we set false to not append directly overwrite the previous content;

Let's test it out:

Log4j.rootlogger=debug, Console, FIEL

#Console

Log4j.appender.console=org.apache.log4j.consoleappender

Log4j.appender.console.layout=org.apache.log4j.ttcclayout

#FIEL

Log4j.appender.FIEL = Org.apache.log4j.FileAppender

Log4j.appender.FIEL.File = C://log.log

Log4j.appender.FIEL.layout = Org.apache.log4j.PatternLayout

Log4j.appender.FIEL.layout.ConversionPattern =%d [%t]%-5p [%c]-%m%n

Log4j.appender.FIEL.Append = False

Changed to Append false.

Test class:

Package com.open1111; import Org.apache.log4j.Logger; Public classTest {Private StaticLogger Logger=logger.getlogger (Test.class);//Get Logger instance          Public Static voidMain (string[] args) {Logger.info ("General Info Info"); Logger.debug ("Debugging Debug Information"); Logger.error ("Error Message"); Logger.warn ("warning warn information"); Logger.fatal ("fatal error fatal information"); Logger.error ("error Message",NewIllegalArgumentException ("Illegal parameters")); }     }

The first time we performed:

We modified the test code:

Package com.open1111; import Org.apache.log4j.Logger; Public classTest {Private StaticLogger Logger=logger.getlogger (Test.class);//Get Logger instance          Public Static voidMain (string[] args) {Logger.info ("General Info Info 22222222222222"); Logger.debug ("Debugging Debug Information"); Logger.error ("Error Message"); Logger.warn ("warning warn information"); Logger.fatal ("fatal error fatal information"); Logger.error ("error message 222222222222222",NewIllegalArgumentException ("Illegal parameters")); }     }

By default Append True

is appended, we append here false

The result is an overlay of the previous

OK This property we understand can use the default true;

Log4j Append property specifies whether to append content

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.