dcsimg
Single class logging filter functionality in Log4j
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   milana_raber
Posted On:   Monday, November 25, 2002 09:41 AM

Is there a way to configure the xml configuration file in Log4j to enable one class logging to a specific file. Such that any other classes, even within the same package, log somewhere else.

thank you in advance

milana

Re: Single class logging filter functionality in Log4j

Posted By:   Christopher_Schultz  
Posted On:   Monday, November 25, 2002 12:03 PM

Yes.



What you want to do is set up two appenders. Make one of them be the default appender for the root category.



Make another category for your 'special' class. Categories typically have the same name as the fully-qualified classname of the class in which they're used, so just mention that category in the config file. Make sure that the special category points to another appender that goes to the file that you want.



The trick is to set the additivity of the special category to false. This makes the difference between log messages that go to both files, and those that go to just one file.



Hope that helps,

-chris
About | Sitemap | Contact