Scott
Scott

Reputation: 75

How to set logging level for JDBCDriverLogging

I am trying to change the logging level to stop showing millions of this:

<May 26, 2010 10:26:02 AM EDT> <Debug> <JDBCDriverLogging> <000000> <2336: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |                |> 

I have tried adding this to my java line:

-Djava.util.logging.config.file=/foo/bar/logging.properties

With this as my logging.properties file:

handlers = java.util.logging.ConsoleHandler
.level = OFF
java.util.logging.ConsoleHandler.level = INFO

No luck. I have tried this:

Logger logger = Logger.getLogger("com.microsoft.sqlserver.jdbc");
Handler handler = new ConsoleHandler();
handler.setLevel(Level.INFO);
logger.addHandler(handler);
logger.setLevel(Level.INFO);
logger.setUseParentHandlers(false);

No luck. I have searched around and all ideas center around one of these two options, so I must be doing something else wrong

I am using jtds-1.2.2.jar.

Thanks for any suggestions.

Upvotes: 0

Views: 3726

Answers (2)

Adam
Adam

Reputation: 5445

Well I doubt you need this now but I came to your question trying to find a way to activate jTDS logging, the opposite to what you needed.

The only way I can find to get the logging to work is to hard-code a Logger like in this question: Log4J: How do I redirect an OutputStream or Writer to logger's writer(s)? and to pass it in to jTDS's Logger.setLogWriter():

    PrintWriter logger = new PrintWriter(
            new LogOutputStream(
                    LoggerFactory.getLogger(Logger.class),
                    Level.DEBUG));
    Logger.setLogWriter(logger);

Maybe in 6 years' time someone else will find this useful ;)

Upvotes: 1

Daniel
Daniel

Reputation: 28074

net.sourceforge.jtds.util.Logger.setLogWriter(new NullPrintWriter()) 

disables logging the Driver. The NullPrintWriter can be either found in the Apache Commons IO package, or implemented for yourself simple by extending PrintStream and replacing the print ops with no ops.

Upvotes: 1

Related Questions