This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes Multiple appenders in Log4j Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Multiple appenders in Log4j" Watch "Multiple appenders in Log4j" New topic
Author

Multiple appenders in Log4j

Senthil Kumar Sekar
Ranch Hand

Joined: Aug 08, 2010
Posts: 45

I want certain logs(irrespective of log levels) in console and certain others in File.BUT NOT IN BOTH.
Is it possible to implement the same using log4j?

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10240
    
168

Yes, that's possible. Take a look at the log4j manual on the project site. Pay attention to the additive (or was it additivity) attribute on the category/logger element in log4j.xml.

[My Blog] [JavaRanch Journal]
Senthil Kumar Sekar
Ranch Hand

Joined: Aug 08, 2010
Posts: 45

Thanks Jai. I got it done by having the additive="false" property.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Multiple appenders in Log4j