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

JavaLoggingLog4j

Java Problem Overview


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>

Java Solutions


Solution 1 - Java

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser3433510View Question on Stackoverflow
Solution 1 - JavaDuncan JonesView Answer on Stackoverflow