我正在使用ECLIPSE IDE(No Maven)编写JAX-RS和Hibernate项目。 对于Hibernate,我使用以下包:
hibernate version 4.3.1 Final
对于Logging我正在使用Log4J
并且它正常工作,但是对于所有与Hibernate相关的日志,它会打印数千个调试消息,我将在下面粘贴一些Log消息。
Log4J没有被用于休眠内部配置。正如根据文档阅读使用Log4J for Logging而不是Simple SLF logger,我在类路径中有以下jar:
即使添加了上面的jar文件,它仍然打印了所有大量的DEBUG消息,我不知道是否错过了一些步骤来消除来自hibernate初始化的日志。
我想从hibernate jar中删除所有其他日志,并仅使用我的Log4J设置来记录消息。
我使用的是eclipse IDE,而不是Maven或pom文件。
以下是其他信息:
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)']
答案 0 :(得分:0)
您的问题可能是Hibernate 4从使用slf4j切换到jboss自己的日志记录外观,称为jboss-logging。
看看这个问题及其答案:How do you configure logging in Hibernate 4 to use SLF4J
他们会详细介绍并提供有关如何使用您的配置登录slf4j以及随后登录log4j的建议。