I would like to use slf4j+logback for two purposes in my application - log and audit.
For logging, I log the normal way:
static final Logger logger = L
Solutions:
Add additivity="false"
to the "AUDIT_LOGGER"
, as described in one of the answers above, to not inherit the appenders from the root
logger.
Remove the appender
element from the "AUDIT_LOGGER"
. This will cause the "AUDIT_LOGGER"
to inherit the appenders from the root
logger.
Be careful including other config files, which can also cause duplicate logging. In my case, I had to remove base.xml
include block, which defines a root logger and appenders.
NOTE: I would suggest defining the appenders outside of your loggers an referring to them by the appender-ref
element. This way you can have multiple loggers referring to the same appender. See logback docs.
%d{HH:mm:ss.SSS}|%msg%n