开发者

logging stderr and stdout with log4j

开发者 https://www.devze.com 2023-01-30 10:06 出处:网络
Following the receipt on log4j redirect stdout to DailyRollingFileAppender And it was working until some point, and then it stopped working for some unknown reason.

Following the receipt on log4j redirect stdout to DailyRollingFileAppender

And it was working until some point, and then it stopped working for some unknown reason.

Any idea of what can be wrong? i verified and im running exactly the same code as tieSystemOutAndErrToLog.

My log4j.properties is:

log4j.rootLogger = INFO, rollingFile, CONSOLE

log4j.logger.org.hibernate=INFO
log4j.logger.com.mchange=INFO
log4j.logger.com.opensymphony=WARN
log4j.logger.com.opensymphony.xwork2.ognl=ERROR

log4j.logger.org.hibernate.SQL=DEBUG, rollingFile
log4j.additivity.org.hibernate.SQL=false

#log4j.logger.com.mchange.v2.c3p0.impl.NewPooledConnection=DEBUG
#log4j.logger.com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool=DEBUG
#log4j.logger.com.mchange.v2.c3p开发者_Python百科0.impl.DefaultConnectionTester=DEBUG
log4j.logger.com.mchange.v2.resourcepool.BasicResourcePool=INFO


log4j.appender.rollingFile=org.apache.log4j.RollingFileAppender
log4j.appender.rollingFile.File=/export/log/alpha/frontend.log
log4j.appender.rollingFile.MaxFileSize=10MB
log4j.appender.rollingFile.MaxBackupIndex=5
log4j.appender.rollingFile.layout = org.apache.log4j.PatternLayout
log4j.appender.rollingFile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} - %p %t %c - %m%n

log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} - %p %t %c - %m%n

in particular, im not able to log this event that is logged in catalina.out:

Dec 10, 2010 1:40:29 AM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException

UPDATED ANSWER: so i finally figured this out. for some obscure reason that i cannot even fathom, tomcat is not routing uncaught exceptions through log4j, and they are dumped to stdout, i had to log them in an exception page..


Is it possible that you reference a JAR file that contains its own log4j.property?


You can add "-Dlog4j.debug" to see which log4j file you're using


No permissions (of the Tomcat process owner) to write into target log file? :)

0

精彩评论

暂无评论...
验证码 换一张
取 消