views:

45

answers:

1

In 3rd party jar logger exist this code. 'Logger.getLogger("net.java.ao").log(Level.INFO, sql.toString());'
How can I disable this logger from my program?

+1  A: 

You could try to raise the LogLevel for the given logger-name "net.java.ao". Therefore, try to specify a custom Logger-configuration using the Java System-Property: "java.util.logging.config.file".

In the file you specified using the above system property, you can simply add the following line:

net.java.ao.level = OFF

Alternatively, you can also use the System-property: "java.util.logging.config.class", as described in the API docs: http://download.oracle.com/docs/cd/E17476_01/javase/1.5.0/docs/api/java/util/logging/LogManager.html.

Javaguru
:(it is not influence - all of ways
EK
maybe, because it is 3rd party jar?
EK
You could try to set a JUL-configuration directly within your Main-Class' static initialization block:static { LogManager lm = LogManager.getLogManager(); lm.reset(); String config ="handlers = java.util.logging.ConsoleHandler\n" + ".level = OFF\n"+ "java.util.logging.ConsoleHandler.level = OFF\n" + "java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter\n"; lm.readConfiguration(new ByteArrayInputStream(config.getBytes()));}
Javaguru