log4j additivity function

Source: Internet
Author: User
Tags log log log4j

The internet is very popular log4j configuration files, where the beginning of a paragraph is like this


Log4j.addivity.org.apache=true # applies to console Log4j.appender.console=org.apache.log4j.consoleappender

Log4j.appender.threshold=debug Log4j.appender.console.target=system.out log4j.appender.console.layout= Org.apache.log4j.PatternLayout Log4j.appender.console.layout.conversionpattern=[framework]%d-%c-%-4r [%t]%-5%x-% m%n #log4j. Appender.console.layout.conversionpattern=[start]%d{date}[date]%n%p[pri Ty]%n%x[ndc]%n%t[thread] n%c[ category]%n%m[message]%n%n Log4j.addivity.org.apache=true

Log4j.addivity.org.apache=true Whether it's true/false, you'll find that the log output doesn't change anything.

The correct format should be:


The role of additivity is to children-logger whether to use Rootlogger configuration, such as an output terminal.

Examples are as follows:

Java code

public static void Main (string[] args) {for (int i = 0; I < 1000;i + +) Logger.debug ("Rollingfileappendertest:" + i);}




If additivity is false, only one rollinglogfile.log log file is generated, and there is no log information output on the screen. If additivity is true, log information is displayed on the screen (because Rootlogger's log output terminal is a stdout-screen), and rollinglogfile.log log files are generated.

additivity defaults to True in log4j. This explains why there are times when a log message has multiple outputs on the screen.

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.