-1

I am writing a project with JAX-RS and Hibernate, using ECLIPSE IDE (No Maven). For Hibernate I am using the below Packages:

hibernate version 4.3.1 Final

For Logging i am using Log4J and its working fine, but for all Hibernate related logs it's printing the debug messages like thousands of then, I will paste some of the Log messages below.

The Log4J is not getting utilized for the hibernate internal configurations. As read per documentation to utilize the Log4J for Logging instead of Simple SLF logger, I have the below jars in the class path:

  1. slf4j.api-1.6.1
  2. slf4j-log4j12-1.6.1
  3. log4j-1.2.17.

Even after adding the above jar files its still printing all the tons of DEBUG messages, I do not know if I missed some step to eliminate the logs coming from hibernate initializations.

I want to eliminate all the additional logs from the hibernate jar's and use only my Log4J settings to log the messages.

I am using eclipse IDE and not Maven or pom file.

Here are the additional information:

Log4J Properties:
log4j.rootLogger=ERROR, stdout
log4j.logger.org.hibernate=ERROR
log4j.logger.org.hibernate.hql.ast.AST=INFO

Hibernate config:

<property name="connection.datasource">Test</property>
<property name="connection.pool.size">1</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="connection.autocommit">false</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="show_sql">false</property>
<mapping resource="DBMappingOracle.hbm.xml" />

and dbmapping file has
<class name="com.text.model.IssueType" table="ISSUE_TYPE">
<id name="issueTypeID" column="ISSUE_ID" type="int" />
<property name="id" column="CATEGORY_ID" type="int" />
<property name="issuename" column="ISSUE_NAME" type="string" />
<property name="issueDesc" column="ISSUE_DESC" type="string" />
</class>

Here is the session code:
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory sf = cfg.buildSessionFactory();
Session session = sf.openSession();




DEBUG MESSAGES i SEE, like 1000's of them like below ones.

//2354 [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] //DEBUG org.hibernate.hql.internal.ast.ErrorCounter  - throwQueryException() : no errors
//2354 [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] //DEBUG org.hibernate.hql.internal.ast.ErrorCounter  - throwQueryException() : no errors
//2363 [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] //DEBUG org.hibernate.hql.internal.ast.QueryTranslatorImpl  - HQL: From //com.ejgallo.distributor.claims.model.IssueSubType
//2363 [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] //DEBUG org.hibernate.hql.internal.ast.QueryTranslatorImpl  - HQL: From //com.ejgallo.distributor.claims.model.IssueSubType
//2363 [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] //DEBUG org.hibernate.hql.internal.ast.QueryTranslatorImpl  - SQL: select //issuesubty0_.ISSUE_SUBTYPE_ID as ISSUE_SU1_3_, issuesubty0_.ISSUE_ID as ISSUE_ID2_3_, //issuesubty0_.ISSUE_SUBTYPE_NAME as ISSUE_SU3_3_, issuesubty0_.ISSUE_SUBTYPE_DESC as //ISSUE_SU4_3_ from ISSUE_SUBTYPE issuesubty0_
//2363 [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] 
Cyclonecode
  • 29,115
  • 11
  • 72
  • 93
vijju
  • 25
  • 6

1 Answers1

1

Your problem might be that Hibernate 4 switched from using slf4j to jboss's own logging facade called jboss-logging.

Have a look at this question and its answers: How do you configure logging in Hibernate 4 to use SLF4J

They go into details and provide suggestions on how to get your logging to slf4j - and subsequently to the log4j using your configuration.

Community
  • 1
  • 1
sheltem
  • 3,754
  • 1
  • 34
  • 39
  • Hi Sheltem, Thank you for the response, i tried adding this to the weblogic start up: -Dorg.jboss.logging.provider=log4j. by following the above link you suggested, somehow this did not seem working. the above link talks more about project from Maven. i am using eclipse IDE and generate a ear for weblogic deploymnet. – vijju Feb 11 '14 at 19:42
  • @vijju The information about the dependencies is the same though, no matter whether you provide them yourself or let maven handle it. – sheltem Feb 11 '14 at 19:46
  • Hi Sheltem, somehow i have all the dependencies and the system property to say use log4j and log4j properties, except the hibernate code rest all is using the log4j and this hibernate related api's or config is dumping all the extra logs. Can you clearly tell what are the steps. the other link is confusing. – vijju Feb 11 '14 at 21:25
  • @vijju I can't give a clear description of what to do because I don't know exactly what the problem is. But can you try using `-Dorg.jboss.logging.provider=slf4j`, so jboss-logging routes to slf4j first? – sheltem Feb 11 '14 at 21:28
  • Sheltem, I tried slf4j it did not work either. I have verified Log4j-1.2.17 and it has the org.apache.log4j.Hierarchy as described in the other article where the loader uses that class, we have the system property and i see the same is available in run time. and the jboss-logging-3.1.3.GA.jar has LoggerProvider Class. Not sure what is missing and why the tons of debug messages are coming from. not sure if some classes are conflicting. – vijju Feb 11 '14 at 21:46
  • i see this 56 DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Log4jLoggerProvider, But the Log4J properties are not being used, any idea why this can happen? – vijju Feb 12 '14 at 00:20