This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
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 ]