Why is the root logger collecting all log types regardless the configuration?

The root logger resides at the top of the logger hierarchy. It is exceptional in three ways:

  • it always exists,
  • its level cannot be set to null
  • it cannot be retrieved by name.

The rootLogger is the father of all appenders. Each enabled logging request for a given logger will be forwarded to all the appenders in that logger as well as the appenders higher in the hierarchy (including rootLogger)

For example, if the console appender is added to the root logger, then all enabled logging requests will at least print on the console. If in addition a file appender is added to a logger, say L, then enabled logging requests for L and L's children will print on a file and on the console. It is possible to override this default behavior so that appender accumulation is no longer additive by setting the additivity flag to false.

From the log4j manual

To sum up:

If you want not to propagate a logging event to the parents loggers (say rootLogger) then add the additivity flag to false in those loggers. In your case:

<logger name="org.springframework.ws.server.endpoint.interceptor"
        <level value="DEBUG" />
        <appender-ref ref="payloadAppender" />

In standard log4j config style (which I prefer to XML):

log4j.logger.org.springframework.ws.server.endpoint.interceptor = INFO, payloadAppender
log4j.additivity.org.springframework.ws.server.endpoint.interceptor = false

Hope this helps.

Leave a Comment