Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the result of making log4j additivity equals to true or false?

In simple terms what is the result of making additivity="true" or additivity="false" when adding a Log4j configuration for a specific class like this?

<Logger name="com.mypage.glass.TryWindow" level="INFO" additivity="true">   <AppenderRef ref="console"/>   <AppenderRef ref="file"/> </Logger> 
like image 701
user3433510 Avatar asked Mar 27 '14 15:03

user3433510


People also ask

What does additivity mean in log4j?

< root > < level value = "DEBUG" /> < appender-ref ref = "console" /> </ root > </ log4j:configuration >

What is additivity false in log4j?

By default, a logger inherits the appenders from its ancestors. By setting additivity="false" , you prevent this behaviour. In your example, there may be appenders associated with com.

How does log4j logging work?

Log4j allows logged messages to contain format strings that reference external information through the Java Naming and Directory Interface (JNDI). This allows information to be remotely retrieved across a variety of protocols, including the Lightweight Directory Access Protocol (LDAP).

What is log4j file used for?

The output from Log4j can go to the console, but it can also go to an email server, a databaseW table, a log file, or various other destinations. Another great benefit of Log4j is that different levels of logging can be set. The levels are hierarchical and are as follows: TRACE, DEBUG, INFO, WARN, ERROR, and FATAL.


1 Answers

By default, a logger inherits the appenders from its ancestors. By setting additivity="false", you prevent this behaviour.

In your example, there may be appenders associated with com.mypage.glass or com.mypage or even the root logger that would be inherited if you don't set that property to false.

like image 79
Duncan Jones Avatar answered Sep 21 '22 19:09

Duncan Jones