The question is simple. In some logback.xmls I see level as an element:
<logger name="mylog" additivity="false">
<level value="DEBUG" />
<appender-ref ref="fileAppender" />
</logger>
But in some it is written as an attribute:
<logger name="mylog" additivity="false" level="debug">
<appender-ref ref="fileAppender" />
</logger>
What is the difference?
Thanks.
In terms of configuring Logback, there is no difference. Both of the following declarations are functionally identical:
Logback's configurer (have a look at
ch.qos.logback.core.joran.GenericConfigurator.doConfigure()
) creates an identicalLogger
instance for both of these declarations.The only difference - when parsing the configuration - is that the first one manifests in more instances of
ch.qos.logback.core.joran.event.SaxEvent
(start and end events for the logger and for the level) than the second one (start and end events for the logger only).If you are associating a logger with a specific appender then you'll already be defining a logger element body e.g.
In which case defining a
level
within the element body rather than as an attribute might read better but it really is just a case of developer preference.