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
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply 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: 16487
    
    2

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: log4j: assigning logging level per appender
 
Similar Threads
Writing File in Java
Server loggng with log4j Tomcat 6.x
Java Logging and concurrent users
log4j:WARN No appenders could be found for logger
Multiple context logging JBoss-Tomcat