tags:

views:

27

answers:

1

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.

A: 
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.

Daniel
Well, put your line in the logging.properties file but there was no change.
Scott
Then I assume the driver does not use the typical Loggername=Class convention, but logs into a logger named "JDBCDriverLogging". So you would have to add the line "JDBCDriverLogging.level=FATAL". Please respond how this worked out for you.
Daniel
Well, I tried this in both the logging properties file and in the code, no luck. Not sure if this matters, but this is the first debug line in the log:<Jun 10, 2010 3:55:01 PM EDT> <Debug> <JDBCDriverLogging> <000000> <JDBC log stream started at Thu Jun 10 15:55:01 EDT 2010>Thanks for your continued help.
Scott
Switch to Log4J. If log4J is enabled, all java.util.logging aware components will use log4j automatically AFAIK. I used log4j very successful imost of my projects and the config file is easy to setup.
Daniel
Well, I think it is the jTDS database driver that is doing the logging, not application code. So I don't know how I could get the driver to use log4j. Here is the home page: http://jtds.sourceforge.net/
Scott
So, if you log something for yourself, the format differs? Why don't you just look in the jTDS source and see how they are logging?
Daniel
I did, and I see this in the Logger.setActive() method:@deprecated Use the JDBC standard mechanisms to enable logging.I guess I can tweak the source and use a modified version of jTDS, but it really should not be this hard.
Scott