wood burning stoves*
The moose likes Java in General and the fly likes How do I customize JDK logging? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How do I customize JDK logging?" Watch "How do I customize JDK logging?" New topic
Author

How do I customize JDK logging?

Ivan Jouikov
Ranch Hand

Joined: Jul 22, 2003
Posts: 269
I'm using Hibernate and System.out logging and Hibernae dumps too much garbage in there.

Some guys told me that I should do this:



And copy logging.properties from jre and modify the following line:

.level=

So I set it to Finer, adnd I do the property thing, but I have absolutely no indication as to whether JDK is using that file or not, and Hibernate keeps logging garbage...

Does anybody know how can I find out if it's working or not, and if not, how do I get it to?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

System.out gives you a PrintStream. If you want to log properly you will need to use a Logger. Have a look at the java.util.logging package. There are lots of ways to do this, but rather than writing

to log you could do this:

Then if you define a java.util.logging.config.file and set the logging level to "INFO" any messages logged at "FINE" will be ignored.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ivan Jouikov
Ranch Hand

Joined: Jul 22, 2003
Posts: 269
Well I'm not the one doing logging, Hibernate is, and they claim they're using JDK logging when no log4j is present (which is my case).

I set

.level= WARNING

inside the logging.properties file and I set the system property... But I sitll see INFO messages:

INFO: building session factory
Jul 18, 2005 11:44:36 AM net.sf.ehcache.config.Configurator configure
WARNING: No configuration found.

How can I check if JDK is in fact using my file?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Hibernate logs nothing to System.out, neither does it use the JDK's logging package directly. It uses Apache commons-logging as its logging framework, and that in turn will use the java.util.logging package if you configure it to. You need to check that you don't have a logging.properties file under JAVA_HOME/jre/lib - as you will by default, which is set to log everything from INFO and above.
Ivan Jouikov
Ranch Hand

Joined: Jul 22, 2003
Posts: 269
Well Hibernate docs say that if it doesn't find log4j, then it will try to use JDK...

I do have that file, and I don't want to use it for this particular application, so I'm trying to copy it and sent a system property but it doesn't seem to be working very well
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I customize JDK logging?
 
Similar Threads
java logging : java.util.logging.config.file - accessing logging.properties in classpath
Java Web Start and JDK Logger
JDK Logger
How to read logging.properties from inside jar file?
slf4j logging issue - log file not getting generated