log4j文件在JBOSS 7.1.1中没有跟踪任何内容

时间:2012-04-24 22:47:06

标签: spring jboss log4j

我在JBoss 7.1.1.FINAL中使用log4j创建了一个spring应用程序,这是我对log4j的配置:

# Log4j level and names.
log4j.rootLogger=INFO, stdout, fileAppender
# Log4j relative path.
dir=${myWebapp-instance-root}
file=WEB-INF/logs/app.log
target=${dir}/${file}
# Used only for development.
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} [%t] %-5p (%F\:%L) \u2013 %m%n
log4j.logger.net.sf.ehcache=TRACE
# Log4j internal message debug , only on console .
log4j.debug=true
# File appender used in production.
log4j.appender.fileAppender=org.apache.log4j.RollingFileAppender
#log4j.appender.fileAppender.File=${app.logdir}/app.log
log4j.appender.fileAppender.File=${target}

log4j.appender.fileAppender.MaxFileSize=1MB
log4j.appender.fileAppender.MaxBackupIndex=5

log4j.appender.fileAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.fileAppender.layout.ConversionPattern=%d{ISO8601} %t %p %c \u2013 %m%n

目录和文件已创建,但在app.log中没有任何内容(白页) Jboss在运行应用程序时没有给出任何错误,这是log4j的一部分:

17:01:33,342 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/projvehimerc]] (MSC service thread 1-1) Initializing log4j from [/opt/jboss-as-7.1.1.Final/standalone/deployments/projvehimerc.war/WEB-INF/log4j-webapp.properties]
17:01:33,351 INFO  [stdout] (MSC service thread 1-1) log4j: Parsing for [root] with value=[INFO, stdout, fileAppender].
17:01:33,352 INFO  [stdout] (MSC service thread 1-1) log4j: Level token is [INFO].
17:01:33,354 INFO  [stdout] (MSC service thread 1-1) log4j: Category root set to null
17:01:33,355 INFO  [stdout] (MSC service thread 1-1) log4j: Parsing appender named "stdout".
17:01:33,367 INFO  [stdout] (MSC service thread 1-1) log4j: Parsing layout options for "stdout".
17:01:33,414 INFO  [stdout] (MSC service thread 1-1) log4j: Setting property [conversionPattern] to [%d{ISO8601} [%t] %-5p (%F:%L) – %m%n].
17:01:33,416 INFO  [stdout] (MSC service thread 1-1) log4j: End of parsing for "stdout".
17:01:33,417 INFO  [stdout] (MSC service thread 1-1) log4j: Parsed "stdout" options.
17:01:33,418 INFO  [stdout] (MSC service thread 1-1) log4j: Parsing appender named "fileAppender".
17:01:33,421 INFO  [stdout] (MSC service thread 1-1) log4j: Parsing layout options for "fileAppender".
17:01:33,422 INFO  [stdout] (MSC service thread 1-1) log4j: Setting property [conversionPattern] to [%d{ISO8601} %t %p %c – %m%n].
17:01:33,423 INFO  [stdout] (MSC service thread 1-1) log4j: End of parsing for "fileAppender".
17:01:33,429 INFO  [stdout] (MSC service thread 1-1) log4j: Setting property [file] to [/opt/jboss-as-7.1.1.Final/standalone/deployments/projvehimerc.war//WEB-INF/logs/app.log].
17:01:33,430 INFO  [stdout] (MSC service thread 1-1) log4j: Setting property [maxBackupIndex] to [5].
17:01:33,430 INFO  [stdout] (MSC service thread 1-1) log4j: Setting property [maxFileSize] to [1MB].
17:01:33,431 INFO  [stdout] (MSC service thread 1-1) log4j: setFile called: /opt/jboss-as-7.1.1.Final/standalone/deployments/projvehimerc.war//WEB-INF/logs/app.log, true
17:01:33,432 INFO  [stdout] (MSC service thread 1-1) log4j: setFile ended
17:01:33,432 INFO  [stdout] (MSC service thread 1-1) log4j: Parsed "fileAppender" options.
17:01:33,433 INFO  [stdout] (MSC service thread 1-1) log4j: Parsing for [net.sf.ehcache] with value=[TRACE].
17:01:33,433 INFO  [stdout] (MSC service thread 1-1) log4j: Level token is [TRACE].
17:01:33,433 INFO  [stdout] (MSC service thread 1-1) log4j: Category net.sf.ehcache set to null
17:01:33,433 INFO  [stdout] (MSC service thread 1-1) log4j: Handling log4j.additivity.net.sf.ehcache=[null]
17:01:33,434 INFO  [stdout] (MSC service thread 1-1) log4j: Finished configuring.

以下

17:01:36,680 INFO  [stdout] (Finalizer) log4j: Finalizing appender named [stdout].
17:01:36,681 INFO  [stdout] (Finalizer) log4j: Finalizing appender named [fileAppender].
像我说文件是创建但没有任何东西,虽然级别是INFO,为什么?

1 个答案:

答案 0 :(得分:4)

确保excluding服务器log4j库jboss-deployment-structure.xml。{{3}}。在JBoss AS 7.1.x中,您需要排除log4j的服务器版本。这应该在7.2.x中修复。