logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Smith <psm...@aconex.com>
Subject Re: Silencing log4j Mystery Output
Date Mon, 09 Jul 2007 22:23:34 GMT

On 10/07/2007, at 7:51 AM, Tom Purl wrote:

> I'm writing a simple java program that uses a third-party, proprietary
> library.
> If I don't place any log4j-related code in my program and run it, I  
> get
> the following output every time:
>
>      [INFO] Resource file for com.foo.String =
> jar:file:/C:/lib/ext_lib.jar!/com/foo/Strings_en_US
>      [INFO] Resource file for com.foo.String =
> jar:file:/C:/lib/ext_lib.jar!/com/foo/Strings_en_US
>
> I would really like to silence this output without forcing the end  
> user
> to do any shell magic.  So I tried placing the following lines of code
> in my program (which has worked in other situations):
>
>     org.apache.log4j.BasicConfigurator.configure();
>     Logger LOG = Logger.getRootLogger();
>     LOG.setLevel((Level)Level.OFF);


Try adding -Dlog4j.debug=true to your JVM startup options.  That  
should output the details of the configuration step that is being  
done (if it's being configured by DOMConfigurator or  
PropertyConfigurator).

You've chosen to set the Root logger to OFF, but that doesn't mean  
that child loggers have not specifically set a level for themselves.   
Try setting the LoggerRepository threshold to OFF.

LogManager.getLoggerRepository().setThreshold(Level.OFF);

This will turn the logging tap off at the root of the hierarchy,  
preventing ANY log4j events from being emitted at all.

cheers,

Paul

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message