【发布时间】:2014-03-08 19:44:43
【问题描述】:
我正在使用 ECLIPSE IDE(无 Maven)使用 JAX-RS 和 Hibernate 编写一个项目。 对于 Hibernate,我使用以下软件包:
hibernate version 4.3.1 Final
对于日志记录,我使用的是Log4J,它工作正常,但对于所有与 Hibernate 相关的日志,它正在打印成千上万条调试消息,我将在下面粘贴一些日志消息。
Log4J 没有被用于休眠内部配置。根据文档阅读以使用 Log4J 进行日志记录而不是简单的 SLF 记录器,我在类路径中有以下 jar:
- slf4j.api-1.6.1
- slf4j-log4j12-1.6.1
- log4j-1.2.17.
即使添加了上面的 jar 文件,它仍然会打印出大量的 DEBUG 消息,我不知道我是否错过了一些步骤来消除来自休眠初始化的日志。
我想从休眠 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)']
【问题讨论】:
标签: java hibernate logging log4j slf4j