Log4J通常在我们的servlet环境中使用几个小时后失败了(运行在带有Java 1.6u31的CentOS 5.5上的tomcat 7.0.26)。发生此错误后,在重新启动tomcat之前不会再进行日志记录。另一个非常奇怪的事情是,有时日志记录请求被刷新到提供的jsps。记录大约10行左右,然后是它下面的html页面。我们正在使用最新的log4j jar。
这些日志来自catalina.out。我们的应用程序特定日志就此停止。
log4j:ERROR Failed to flush writer,
java.io.IOException: Bad file descriptor
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(Unknown Source)
at sun.nio.cs.StreamEncoder.writeBytes(Unknown Source)
at sun.nio.cs.StreamEncoder.implFlushBuffer(Unknown Source)
at sun.nio.cs.StreamEncoder.implFlush(Unknown Source)
at sun.nio.cs.StreamEncoder.flush(Unknown Source)
at java.io.OutputStreamWriter.flush(Unknown Source)
at org.apache.log4j.helpers.QuietWriter.flush(QuietWriter.java:59)
at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:324)
at org.apache.log4j.RollingFileAppender.subAppend(RollingFileAppender.java:276)
at org.apache.log4j.WriterAppender.append(WriterAppender.java:162)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
at org.apache.log4j.Category.callAppenders(Category.java:206)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.info(Category.java:666)
...
log4j:ERROR Could not close org.apache.log4j.helpers.CountingQuietWriter@1e7abbd
java.io.IOException: Bad file descriptor
at java.io.FileOutputStream.close0(Native Method)
at java.io.FileOutputStream.close(Unknown Source)
at sun.nio.cs.StreamEncoder.implClose(Unknown Source)
at sun.nio.cs.StreamEncoder.close(Unknown Source)
at java.io.OutputStreamWriter.close(Unknown Source)
at java.io.FilterWriter.close(Unknown Source)