-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: Hibernate System.err console logging
PostPosted: Tue Sep 03, 2013 2:08 pm 
Newbie

Joined: Tue Sep 03, 2013 2:03 pm
Posts: 5
Hibernate appears to be logging normal information to System.err. A few examples are:

Code:
    System.err: Sep 03, 2013 10:41:55 AM org.hibernate.annotations.common.Version <clinit>
    System.err: Sep 03, 2013 10:41:55 AM org.hibernate.Version logVersion
    System.err: Sep 03, 2013 10:41:55 AM org.hibernate.cfg.Environment <clinit>
    System.err: Sep 03, 2013 10:41:55 AM org.hibernate.cfg.Environment buildBytecodeProvider
    System.err: Sep 03, 2013 10:42:02 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>


There are about 70 of these in total. My logging setup is as follows:

Code:
    log4j-over-slf4j.jar
    slf4j-api.jar
    slf4j-simple-1.7.5.jar


I know that slf4j-simple, per the SLF4J Manual (http://www.slf4j.org/manual.html), "outputs all events to System.err. Only messages of level INFO and higher are printed."

Knowing this, I set the org.slf4j.simpleLogger.logFile system property to System.out as specified in the SimpleLogger docs (http://www.slf4j.org/apidocs/org/slf4j/impl/SimpleLogger.html).

This didn't change any behavior, however, and I am still getting 70+ Hibernate System.err logs.

Is there any way to configure Hibernate to not output to System.err? The problem is that these System.err messages are being interpreted as WARNs while they are only informational messages.


Top
 Profile  
 
 Post subject: Re: Hibernate System.err console logging
PostPosted: Wed Sep 04, 2013 6:31 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
I'm not sure but I think you should change the property file you are using in your application.

If you add the log4j.properties file to your classpath and change the part that logs to the console to something like this:
Code:
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{3}:%L - %m%n

log4j.rootLogger=INFO, stdout


You should be able to see the messages as System.out instead of System.err
This is the part that should be set as System.out:
Code:
log4j.appender.stdout.Target=System.out


Top
 Profile  
 
 Post subject: Re: Hibernate System.err console logging
PostPosted: Wed Sep 04, 2013 9:31 am 
Newbie

Joined: Tue Sep 03, 2013 2:03 pm
Posts: 5
Thanks for the reply. We had removed our log4j.properties file because I thought we wouldn't need them anymore. Is that possibly not the case?


Top
 Profile  
 
 Post subject: Re: Hibernate System.err console logging
PostPosted: Wed Sep 04, 2013 9:48 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
As far as I know if you are using log4j with hibernate in a standalone application that's the way you configure the properties.
If you are deploying the application on a container there might be other approaches.


Top
 Profile  
 
 Post subject: Re: Hibernate System.err console logging
PostPosted: Wed Sep 04, 2013 9:52 am 
Newbie

Joined: Tue Sep 03, 2013 2:03 pm
Posts: 5
Thanks for the information. I will mess around with it for a bit and see if I can get anything to work. Does Hibernate output to System.err at all or is something else doing that?


Top
 Profile  
 
 Post subject: Re: Hibernate System.err console logging
PostPosted: Wed Sep 04, 2013 10:20 am 
Newbie

Joined: Tue Sep 03, 2013 2:03 pm
Posts: 5
It appears that the log4j.properties file doesn't have any effect. We're simply using the log4j-over-slf4j bridge and then using slf4j-simple for our logging purposes. We configured slf4j-simple to output to System.out instead of the default System.err but it appears Hibernate is still outputting to System.err.


Top
 Profile  
 
 Post subject: Re: Hibernate System.err console logging
PostPosted: Wed Sep 04, 2013 3:40 pm 
Newbie

Joined: Tue Sep 03, 2013 2:03 pm
Posts: 5
Alright, I figured out the solution. Hibernate 4.x now uses JBoss Logging as opposed to SLF4J in 3.x. Given my specific configuration JBoss needs to be told what provider to use through the system property:
Code:
org.jboss.logging.provider=slf4j


After I made that change I was able to set the system property for SLF4J-simple to System.out and all was resolved.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.