You problem is with the <root>
section, the root section captures all logs, and you've told it to log to both appenders...
You could remove it, or set additivity="false"
on each of your logger
elements - this will tell log4j not to log the same log through 'root' if it's already been logged through one of your 'logger's.
Edit: you don't say which version of log4j you are using, but I'm using log4j-1.2.16, and using the file in your post, it fails completely for me because it doesn't like the <appender ref="fileAppender1"/>
, it wants them to be <appender-ref ref="fileAppender1"/>
(note the -ref
after the appender). If I add these in, and also add the additivity attributes that I suggested, then for me it works as you expect.