アプリケーションで log4j を使用して、特定のパッケージを異なるログ レベルでログに記録しています。
ただし、 stderr と stdout はこのログファイルにキャプチャされていないようで、代わりに、アプリの起動時にファイルに出力されています
java AppName >> out.log
out.log ファイルだけでなく、log4j で stdout と stderr をキャッチすることは可能ですか (例: stdout を info として、stderr を WARN/ERROR として)。
log4j の設定は次のとおりです。
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="FileAppender" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="${MDCapture.logfile.dir}/${APP_NAME}.log"/>
<param name="BufferedIO" value="false"/>
<param name="DatePattern" value="'.'yyyy-MMM-dd"/>
<layout class="org.apache.log4j.TTCCLayout">
<param name="DateFormat" value="ISO8601"/>
</layout>
</appender>
<appender name="AsyncAppenders" class="org.apache.log4j.AsyncAppender">
<appender-ref ref="FileAppender"/>
</appender>
<!-- LOGGER PACKAGES -->
<root>
<priority value="info"/>
<appender-ref ref="AsyncAppenders"/>
</root>
</log4j:configuration>
アップデート:
stackoverflow エラーのスタックトレース:
WARN root buffer size limit:65log4j:WARN root buffer size limit:65Exception in thread "Thread-12"
2013-03-22 09:14:24,451 [Thread-12] ERROR root - java.lang.StackOverflowError
2013-03-22 09:14:24,452 [Thread-12] ERROR root - at java.io.BufferedWriter.write(BufferedWriter.java:202)
2013-03-22 09:14:24,452 [Thread-12] ERROR root - at java.io.Writer.write(Writer.java:140)
2013-03-22 09:14:24,452 [Thread-12] ERROR root - at java.io.PrintStream.write(PrintStream.java:475)
2013-03-22 09:14:24,452 [Thread-12] ERROR root - at java.io.PrintStream.print(PrintStream.java:619)
2013-03-22 09:14:24,452 [Thread-12] ERROR root - at java.io.PrintStream.println(PrintStream.java:756)
2013-03-22 09:14:24,452 [Thread-12] ERROR root - at org.apache.log4j.helpers.LogLog.warn(LogLog.java:171)
2013-03-22 09:14:24,452 [Thread-12] ERROR root - at org.apache.log4j.AsyncAppender.append(AsyncAppender.java:175)
2013-03-22 09:14:24,452 [Thread-12] ERROR root - at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
2013-03-22 09:14:24,452 [Thread-12] ERROR root - at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
2013-03-22 09:14:24,452 [Thread-12] ERROR root - at org.apache.log4j.Category.callAppenders(Category.java:206)
2013-03-22 09:14:24,452 [Thread-12] ERROR root - at org.apache.log4j.Category.forcedLog(Category.java:391)
2013-03-22 09:14:24,452 [Thread-12] ERROR root - at org.apache.log4j.Category.log(Category.java:838)
2013-03-22 09:14:24,453 [Thread-12] ERROR root - at com.company.something.AClass.LoggingOutputStream.flush(LoggingOutputStream.java:198)
2013-03-22 09:14:24,453 [Thread-12] ERROR root - at java.io.PrintStream.write(PrintStream.java:432)
2013-03-22 09:14:24,453 [Thread-12] ERROR root - at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:202)
2013-03-22 09:14:24,453 [Thread-12] ERROR root - at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:272)
2013-03-22 09:14:24,453 [Thread-12] ERROR root - at sun.nio.cs.StreamEncoder.flushBuffer(StreamEncoder.java:85)
2013-03-22 09:14:24,453 [Thread-12] ERROR root - at java.io.OutputStreamWriter.flushBuffer(OutputStreamWriter.java:168)
2013-03-22 09:14:24,453 [Thread-12] ERROR root - at java.io.PrintStream.write(PrintStream.java:477)
2013-03-22 09:14:24,453 [Thread-12] ERROR root - at java.io.PrintStream.print(PrintStream.java:619)
2013-03-22 09:14:24,453 [Thread-12] ERROR root - at java.io.PrintStream.println(PrintStream.java:756)
2013-03-22 09:14:24,453 [Thread-12] ERROR root - at org.apache.log4j.helpers.LogLog.warn(LogLog.java:171)
2013-03-22 09:14:24,453 [Thread-12] ERROR root - at org.apache.log4j.AsyncAppender.append(AsyncAppender.java:175)
2013-03-22 09:14:24,453 [Thread-12] ERROR root - at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
2013-03-22 09:14:24,453 [Thread-12] ERROR root - at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java: