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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2332608/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 06:15:47  来源:igfitidea点击:

Log4j - org.hibernate.type doesn't work!

javahibernatelog4j

提问by Eran Medan

This is my logger configuration:

这是我的记录器配置:

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

but I don't see type bingings

但我没有看到类型绑定

So I tried this

所以我试过这个

log4j.logger.org.hibernate=TRACE, stdout

to see if I missed something (this shows all hibernate loggers) and I found out that the org.hibernate.engine.QueryParameterslogger also shows parameter bindings (still no sign of org.hibernate.type logger binding messages)

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

So then I tried

然后我尝试了

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

but it shows me only logs from the org.hibernate.SQL logger!

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

We use Hibernate 3.2.6.ga with classic query translator

我们使用 Hibernate 3.2.6.ga 和经典查询翻译器

Any clues?

有什么线索吗?

采纳答案by Michel

i use this for hibernate log

我将它用于休眠日志

### 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

you can comment or uncomment several options

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

Attention: your webapp will be a lot slower when you use this. so only use it for debugging

注意:当你使用它时,你的 webapp 会慢很多。所以只用于调试

回答by Steve

It think it is a bug, take a look at HHH-2835

觉得是bug,看看HHH-2835

回答by Evgeniy Bulanov

I faced the same problem with hibernate 3.5.5 and I found out that tracing is enabled by static field in org.hibernate.type.NullableType in the following way:

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

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

So I set in log configuration log level TRACE for org.hibernate.type.Type and restarted a server.

因此,我为 org.hibernate.type.Type 设置了日志配置日志级别 TRACE 并重新启动了服务器。

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