You can have 2 separate loggers in your java code. Each logger will use a separate appender. To avoid code duplication(of the if/else statements in each class where you are using the logger), i would suggest, you create your own wrapper over the log4j's Logger. Something like:
And the classes using the logger will look like:
Your log4j.xml will look like:
The above method looks simple. However, you might want to have a look at some other ways to tackle this, mentioned at
Logging Separation and see if they are better suited in your application
[ July 12, 2006: Message edited by: jaikiran pai ]