我正在使用Hibernate作爲個人項目。 在我的項目,我有這些目錄:無法禁用休眠日誌消息
+ CONF
log4j.properties
+斌
我的班
使用Windows控制檯,我去項目目錄(bin和conf的父親),然後用這樣的命令啓動應用程序:
java -cp conf;lib/lib1.jar;lib/lib2.jar;[etc] com.moc.Main
我log4j.properties文件是這樣(從休眠示例截取):
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 - %m%n log4j.rootLogger=info, stdout log4j.logger.org.hibernate=error log4j.logger.org.hibernate.tool.hbm2ddl=error log4j.logger.org.hibernate.hql.ast.QueryTranslatorImpl=error log4j.logger.org.hibernate.hql.ast.HqlSqlWalker=error log4j.logger.org.hibernate.hql.ast.SqlGenerator=error log4j.logger.org.hibernate.hql.ast.AST=error
在應用程序啓動,這是輸出:
2010-11-06 19:00:56,376 - Logger.getRootLogger().info() statement 12 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.5.3-Final 13 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found 16 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist 20 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling 108 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: com/moc/hibernate.cfg.xml 108 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: com/moc/hibernate.cfg.xml 124 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from file: conf\hiber\Customer.hbm.xml . . . and so on . . . 795 [main] INFO org.hibernate.impl.SessionFactoryImpl - closing 795 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - cleaning up connection pool: jdbc:mysql://localhost/mydb
的休眠日誌行的顏色是紅色的,我的日誌線是黑色的。
爲什麼我仍然看到Hibernate的INFO輸出?我究竟做錯了什麼?
Hibernate使用SFL4J進行日誌記錄。你的類路徑中究竟有哪些JAR?什麼SFL4J綁定?你只有log4j作爲日誌後端? – 2010-11-07 09:47:24