aspose file tools*
The moose likes Java in General and the fly likes log4j: assigning logging level per appender Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "log4j: assigning logging level per appender" Watch "log4j: assigning logging level per appender" New topic
Author

log4j: assigning logging level per appender

David Irwin
Ranch Hand

Joined: Mar 25, 2004
Posts: 82
All,

I use log4j extensively in my application. I'm wondering if there's a way to set the logging level based on the appendering being used. For example, my rolling file appender I would like to set to debug logging level, while my console appender I would like to set to info, and my smtp appender to fatal.

I've looked through the log4j manual and while I can set the logging level based on a specific class package (i.e. foo.bar.com set to a different logging level than my root logger), I can't figure out a way to set the logging level based on the appender. Am I missing something?

Thanks,
Dave
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18991
    
    8

I don't think so. I just looked at the API documentation. The Logger class has a setLevel() method and the Appender class doesn't.

You could write an org.apache.log4j.spi.Filter object that denies logging events of whatever level you want to filter out, and add that to the appender in question.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: log4j: assigning logging level per appender