Log4j - org.hibernate.type不起作用!

时间:2010-02-25 08:29:49

标签: java hibernate log4j

这是我的记录器配置:

log4j.logger.org.hibernate.SQL=TRACE, stdout
log4j.logger.org.hibernate.type=TRACE, stdout

但我没有看到打字类型

所以我试过这个

log4j.logger.org.hibernate=TRACE, stdout

看我是否错过了什么(这显示了所有的休眠记录器) 我发现org.hibernate.engine.QueryParameters记录器还显示参数绑定(仍然没有org.hibernate.type记录器绑定消息的迹象)

然后我尝试了

log4j.logger.org.hibernate.SQL=TRACE, stdout
log4j.logger.org.hibernate.type=TRACE, stdout
log4j.logger.org.hibernate.engine.QueryParameters=TRACE, stdout

但它只显示来自org.hibernate.SQL记录器的日志!

我们将Hibernate 3.2.6.ga与经典查询翻译器一起使用

任何线索?

3 个答案:

答案 0 :(得分:28)

我将它用于休眠日志

### Hibernate logging configuration ###  

### Log everything (a lot of information, but very useful for troubleshooting) ###  
#log4j.logger.org.hibernate=info  

### Log HQL and SQL ASTs during query parsing ###  
log4j.logger.org.hibernate.hql.ast.AST=DEBUG, SQL_APPENDER  
log4j.additivity.org.hibernate.hql.ast.AST=false  

### log just the SQL  
log4j.logger.org.hibernate.SQL=DEBUG, SQL_APPENDER  
log4j.additivity.org.hibernate.SQL=false  

### log JDBC bind parameters. Very userfull, when debug parameterized queries ###  
log4j.logger.org.hibernate.type=TRACE, SQL_APPENDER  
log4j.additivity.org.hibernate.type=false  

### log schema export/update ###  
#log4j.logger.org.hibernate.tool.hbm2ddl=info  

### log HQL parse trees  
#log4j.logger.org.hibernate.hql=debug  

### log cache activity ###  
#log4j.logger.org.hibernate.cache=info  

### log transaction activity  
#log4j.logger.org.hibernate.transaction=debug  

### Log all JDBC resource acquisition  
#log4j.logger.org.hibernate.jdbc=debug  

### enable the following line if you want to track down connection ###  
### leakages when using DriverManagerConnectionProvider ###  
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace  

log4j.appender.SQL_APPENDER=org.apache.log4j.RollingFileAppender  
log4j.appender.SQL_APPENDER.File=c\:/EC_sql.log
log4j.appender.SQL_APPENDER.MaxFileSize=1000KB  
log4j.appender.SQL_APPENDER.MaxBackupIndex=62  
log4j.appender.SQL_APPENDER.layout=org.apache.log4j.PatternLayout  
log4j.appender.SQL_APPENDER.layout.ConversionPattern=[%d] %5p [%t] (%F:%L) - %m%n

您可以评论或取消注释多个选项

注意:使用它时,你的webapp会慢得多。所以只能用它来调试

答案 1 :(得分:3)

它认为这是一个错误,请看HHH-2835

答案 2 :(得分:1)

我遇到了与hibernate 3.5.5相同的问题,我发现跟踪是通过org.hibernate.type.NullableType中的静态字段以下列方式启用的:

private static final boolean IS_VALUE_TRACING_ENABLED = LoggerFactory.getLogger( StringHelper.qualifier( Type.class.getName() ) ).isTraceEnabled();

所以我在org.hibernate.type.Type的日志配置日志级别TRACE中设置并重启服务器。

<logger name="org.hibernate.type.Type" level="TRACE">
    <appender-ref ref="myAppender"/>
</logger>