Log output of a specific Class to a specific Appender with log4j

:heavy_exclamation_mark: This post is older than a year. Consider some information might not be accurate anymore. :heavy_exclamation_mark:

An Java application uses log4j. Since I use logback all the time, it was quite a challenge to look up the docs for log4j 1.2.17. This application also writes statistical logs. To separate the statistic, we can use a different appender in log4j. The crucial point is to set the additivity to false, so the log won’t be logged twice in the root logger.

# write statistic to separate log file
# define file, where information is stored
# define layout
log4j.logger.com.riskshield.server.plugin.StatisticPlugin=INFO, STAT
# don't use root logger
Please remember the terms for blog comments.