1

I am using Hibernate, and I have difficulty in disabling the logging for the console even when i have the logback.xml on the classpath I am not able to disable the logging. I have also set Showsql to false. I read else where that We have to disable logging in log4j and other libs. I am listing a list of libs which I have include in the project.They are...

c3p0-0.9.5.jar  477kB   
c3p0-oracle-thin-extras-0.9.5.jar       
commons-pool-1.6.jar    
mchange-commons-java-0.2.9.jar  

commons-codec-1.9-sources.jar   
commons-codec-1.9-test-sources.jar
commons-codec-1.9-tests.jar 
commons-codec-1.9.jar   
commons-collections.jar
commons-digester.jar
commons-io-2.4.jar  
commons-lang-2.1.jar
commons-digester1.6.jar 
commons-fileupload-1.3.1.jar    


commons-logging-1.2.jar     
commons-logging.jar commons-validator.jar   
servlet-api.jar         
hibernate-envers-4.3.6.Final.jar    
hibernate-entitymanager-4.3.6.Final.jar         
hibernate-jpamodelgen-4.3.6.Final.jar
hibernate-osgi-4.3.6.Final.jar  
org.osgi.compendium-4.3.1.jar
org.osgi.core-4.3.1.jar
antlr-2.7.7.jar dom4j-1.6.1.jar
hibernate-commons-annotations-4.0.5.Final.jar   
hibernate-core-4.3.6.Final.jar      
hibernate-jpa-2.1-api-1.0.0.Final.jar   
jandex-1.1.0.Final.jar      
javassist-3.18.1-GA.jar 
jboss-logging-3.1.3.GA.jar  
jboss-logging-annotations-1.2.0.Beta1.jar
jboss-transaction-api_1.2_spec-1.0.0.Final.jar  

Logback.xml as follows:

 <?xml version="1.0" encoding="utf-8"?>
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" threshold="OFF">
    <root>
        <priority value ="off" />
        <appender-ref ref="console" />
        <appender-ref ref="rolling-file" />
    </root>
</log4j:configuration> 

I also added domain.xml as follows:

<system-properties>
<property name="org.apache.cxf.logging.enabled" value="true"/>
</system-properties>

All this is not helping. Thanks.

Abhijeet
  • 84
  • 1
  • 3
  • 9
  • You have a logback.xml, that contains log4j configuration, and you're using jboss-logging? – Kayaman Jan 07 '15 at 06:45
  • I do not have much knowledge about logging dear.. please guide..! – Abhijeet Jan 07 '15 at 08:34
  • Well darling, it sure looks like it. Which logging framework are you actually using, since I doubt you're using all three (logback, log4j and jboss-logging). – Kayaman Jan 07 '15 at 09:03

1 Answers1

0

These two are the configurations to switch off the hibernate sql loggging. Hibernate configuration to switch off the sql. true

Log4j configuration to swithc off the sql logging in log4j.properties. log4j.logger.org.hibernate.SQL=OFF

But as you are using JBoss logging related jar also, please check conf/log4j.xml in JBoss server. Then include the line log4j.logger.org.hibernate.SQL=OFF ,

Else add log4j jar in your war file and have log4j.properties switching off hibernate sql logging.

Nagappan
  • 346
  • 2
  • 8
  • I have removed all the logging jars except Jboss. It seems that without Jboss jar hibernate wil not work... Can i set a property in xml and get rid of these logs please..? – Abhijeet Jan 07 '15 at 10:15
  • Okay jboss logging is a facade, you can add log4j jar to the jboss logging face and have log4j xml. Please check - http://stackoverflow.com/questions/12456069/how-to-use-jboss-logging-brought-by-hibernate. You can add the property and try also. – Nagappan Jan 07 '15 at 11:02
  • one more thing jboss logging is a mandate from Hibernate 4 only. [check](http://docs.jboss.org/hibernate/orm/4.3/topical/html/logging/Logging.html) for clear guidance – Nagappan Jan 07 '15 at 11:21
  • If you include log4j, the same property need to be included in log4j.xml – Nagappan Jan 07 '15 at 11:40
  • Please try first in logBack.xml by adding and then we can put it in log4j.xml. – Nagappan Jan 07 '15 at 11:59
  • Hey Guys I have disabled the sql statements from hibernate using logback.xml but now I am getting c3po statements ... how do it go about the same..disabling it.? Thanks Nagappan – Abhijeet Jan 08 '15 at 13:13
  • will switch off c3p0 and it can be tried in logback.xml itself. Check [Reference] (http://stackoverflow.com/questions/2976308/how-do-i-turn-off-logging-in-java-c3p0-connection-pooling-lib) – Nagappan Jan 08 '15 at 13:48