关闭休眠日志记录控制台输出 [英] Turning off hibernate logging console output
问题描述
我正在使用 hibernate 3 并希望阻止它向控制台转储所有启动消息.我尝试注释掉 log4j.properties 中的 stdout 行,但没有运气.我在下面粘贴了我的日志文件.此外,我正在使用具有标准项目结构的 eclipse,并且在项目文件夹的根目录和 bin 文件夹中都有 log4j.properties 的副本.
I'm using hibernate 3 and want to stop it from dumping all the startup messages to the console. I tried commenting out the stdout lines in log4j.properties but no luck. I've pasted my log file below. Also I'm using eclipse with the standard project structure and have a copy of log4j.properties in both the root of the project folder and the bin folder.
### direct log messages to stdout ###
#log4j.appender.stdout=org.apache.log4j.ConsoleAppender
#log4j.appender.stdout.Target=System.out
#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
#log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### direct messages to file hibernate.log ###
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=hibernate.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### set log levels - for more verbose logging change 'info' to 'debug' ###
log4j.rootLogger=warn, stdout
#log4j.logger.org.hibernate=info
log4j.logger.org.hibernate=debug
### log HQL query parser activity
#log4j.logger.org.hibernate.hql.ast.AST=debug
### log just the SQL
#log4j.logger.org.hibernate.SQL=debug
### log JDBC bind parameters ###
log4j.logger.org.hibernate.type=info
#log4j.logger.org.hibernate.type=debug
### log schema export/update ###
log4j.logger.org.hibernate.tool.hbm2ddl=debug
### log HQL parse trees
#log4j.logger.org.hibernate.hql=debug
### log cache activity ###
#log4j.logger.org.hibernate.cache=debug
### log transaction activity
#log4j.logger.org.hibernate.transaction=debug
### log 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=trac5
推荐答案
尽量设置更合理的日志级别.将日志级别设置为 info
意味着只记录 info
或更高级别的事件(warn
、error
和 >fatal
) 被记录,即 debug
记录事件被忽略.
Try to set more reasonable logging level. Setting logging level to info
means that only log event at info
or higher level (warn
, error
and fatal
) are logged, that is debug
logging events are ignored.
log4j.logger.org.hibernate=info
或在 XML 版本 log4j 配置文件中:
or in XML version of log4j config file:
<logger name="org.hibernate">
<level value="info"/>
</logger>
另请参阅 log4j 手册.
这篇关于关闭休眠日志记录控制台输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!