gpt4 book ai didi

java - hibernate 日志记录

转载 作者:搜寻专家 更新时间:2023-11-01 03:12:23 25 4
gpt4 key购买 nike

我的应用程序将 Hibernate 与 Ehcache 结合使用。

我已经用这个 log4j.properties 配置了 log4j:

# Configure the console as our one appender
log4j.rootLogger = INFO, A1

log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%c] - %m%n

log4j.logger.org.hibernate=info
### log HQL query parser activity
log4j.logger.org.hibernate.hql.ast.AST=info
### log just the SQL
log4j.logger.org.hibernate.SQL=info
### log JDBC bind parameters ###
log4j.logger.org.hibernate.type=info
### log schema export/update ###
log4j.logger.org.hibernate.tool.hbm2ddl=info
### log HQL parse trees
log4j.logger.org.hibernate.hql=info
### log cache activity ###
log4j.logger.org.hibernate.cache=info
### log transaction activity
log4j.logger.org.hibernate.transaction=info
### log JDBC resource acquisition
log4j.logger.org.hibernate.jdbc=info
### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=info

但是在控制台输出中我有很多这样的日志行:

22:42:06.603 [Thread-15] DEBUG org.hibernate.type.BasicTypeRegistry - Adding type registration imm_time -> org.hibernate.type.AdaptedImmutableType@1bdedf8
22:42:06.603 [Thread-15] DEBUG org.hibernate.type.BasicTypeRegistry - Adding type registration imm_timestamp -> org.hibernate.type.AdaptedImmutableType@5264dc
22:42:06.603 [Thread-15] DEBUG org.hibernate.type.BasicTypeRegistry - Adding type registration imm_dbtimestamp -> org.hibernate.type.AdaptedImmutableType@15bd8eb
22:42:06.603 [Thread-15] DEBUG org.hibernate.type.BasicTypeRegistry - Adding type registration imm_calendar -> org.hibernate.type.AdaptedImmutableType@fe4dd2
22:42:06.603 [Thread-15] DEBUG org.hibernate.type.BasicTypeRegistry - Adding type registration imm_calendar_date -> org.hibernate.type.AdaptedImmutableType@1a751ff
22:42:06.603 [Thread-15] DEBUG org.hibernate.type.BasicTypeRegistry - Adding type registration imm_binary -> org.hibernate.type.AdaptedImmutableType@1f86f75
22:42:06.603 [Thread-15] DEBUG org.hibernate.type.BasicTypeRegistry - Adding type registration imm_serializable -> org.hibernate.type.AdaptedImmutableType@15daaef
22:42:06.603 [Thread-15] DEBUG org.hibernate.type.BasicTypeRegistry - Adding type registration materialized_blob -> org.hibernate.type.MaterializedBlobType@9d5241
22:42:06.604 [Thread-15] DEBUG n.s.e.config.ConfigurationFactory - Configuring ehcache from InputStream
22:42:06.606 [Thread-15] DEBUG net.sf.ehcache.config.BeanHandler - Ignoring ehcache attribute xmlns:xsi

是否可以禁用此 DEBUG 消息?我找不到任何可行的解决方案。提前致谢!

附言。 pom.xml 仅包含:

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>

最佳答案

解决了问题:1. 从 spring 中排除 commons-logging:

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>

2。设置日志记录:

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
<version>1.1.1</version>
</dependency>

3。从反射中排除 logback:

<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.5-RC2_jboss-SP1</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<artifactId>logback-classic</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
</exclusions>
</dependency>

对不起,如果我提供的细节很少:)

关于java - hibernate 日志记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7246794/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com