尽管在WEB-INF / classes中,log4j仍未找到.properties文件

时间:2013-01-28 19:15:26

标签: hibernate log4j classloader

我有一个非常讨厌的问题,其中log4j拒绝在我的新项目中找到属性文件。我正在使用Hibernate4,它使用jboss-logging有些不合理的原因。我通过创建资源源文件夹在WEB-INF / classes中有一个log4j.properties。我可以在classes文件夹中看到log4j.properties,所以我知道RAD正在将文件作为源文件。它看起来如下:

log4j.rootLogger=WARN, stdout
log4j.gov.usdoj=INFO

#Direct log messages to the console
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %c{2}[%M:%L] %p %m%n

# Hibernate logging options(INFO only shows startup messages)
#org.hibernate Log everything. This is a lot of information but it is useful for troubleshooting 
log4j.logger.org.hibernate=WARN
#org.hibernate.type Log all JDBC parameters 
log4j.logger.org.hibernate.type=WARN
#org.hibernate.SQL Log all SQL DML statements as they are executed (like show_sql setting) 
log4j.logger.org.hibernate.sql=WARN
#org.hibernate.tool.hbm2ddl Log all SQL DDL statements as they are executed 
log4j.logger.org.hibernate.tool.hbm2ddl=WARN
#org.hibernate.pretty Log the state of all entities (max 20 entities) associated with the session at flush time 
log4j.logger.org.hibernate.pretty=WARN
#org.hibernate.cache Log all second-level cache activity 
log4j.logger.org.hibernate.cache=WARN
#org.hibernate.transaction Log transaction related activity 
log4j.logger.org.hibernate.transaction=WARN
#org.hibernate.jdbc Log all JDBC resource acquisition 
log4j.logger.org.hibernate.jdbc=WARN
#org.hibernate.hql.internal.ast.AST Log HQL and SQL ASTs during query parsing 
log4j.logger.org.hibernate.hql.internal.ast.AST=WARN
#org.hibernate.secure Log all JAAS authorization requests 
log4j.logger.org.hibernate.secure=WARN

但是我已经把故意的错误(比如XML)放在它里面并且没有“爆炸”所以我很确定log4j甚至没有找到它。我在启动时指向(org.hibernate.type.BasicTypeRegistry)时出现“无appenders”错误。我在bootstrap区域有hibernate-jpa,因为RAD运行的是同一个jar的不同版本,如果我们不将hibernate-jpa放在bootstrap区域,我们就会检查Orphan ManyToOne错误。如果有人知道更好的解决方案,我想听听,因为我讨厌这样做。

但是手头的主题是由于某些原因,在这个项目上我无法让log4j找到log4j.properties文件。我有点怀疑我是hibernate事件的类加载器问题的受害者,但log4j.jar在我的WEB-INF / lib中。

0 个答案:

没有答案