On Mon, July 9, 2007 5:23 pm, Paul Smith wrote:
>
> 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.

Ok, I think I found the solution.  I tried the options above, but it
didn't solve the problem.  It appears as though the third-party library
isn't using Log4J, so nothing like this will fix the problem.

We ended up silencing STDOUT right before we invoke the method that
outputs the logging messages, and then un-silencing it immediately
afterwards.  It's not terribly pretty, but it's working pretty well for
us.

Thanks again for the help!

Tom Purl



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to