Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I customize JDK logging?

 
Ivan Jouikov
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ivan Jouikov
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic