You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by bu...@apache.org on 2007/04/18 08:37:01 UTC

DO NOT REPLY [Bug 42151] New: - StackOverFlow in flush() method of LoggingOutputStream

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42151>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42151

           Summary: StackOverFlow in flush() method of LoggingOutputStream
           Product: Log4j
           Version: 1.2
          Platform: Sun
        OS/Version: Solaris
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Appender
        AssignedTo: log4j-dev@logging.apache.org
        ReportedBy: mayank.rao@credit-suisse.com


I am using Log4j as the logging utility for a J2EE (JDK version 1.4) 
application hosted on Weblogic server 8.1 sp2 running on Solaris 8.

The problem (StackOverFlow) occurs in the production environment when several 
jobs are run in parallel. The jobs start at 3:00 am and the error occurs 
between 9-10:30 am every day, but it is not associated with any job in 
paricular. We are unable to replicate this in dev, as the dev machines cannot 
handle the parallel processing of so many jobs. When we run the jobs one after 
another, there is no error.

The exact setup being used is as follows:
1) Each job is run using an instance of a class called WorkflowBo, which gains 
access to Log4j via its constructor in the following way:
      m_logger = Logger.getLogger(p_loggerName);
      e_logger = Logger.getLogger(p_loggerName + "_err");
2) We are using an appender that we downloaded off the Log4j forums called 
ArchivedDailyRollingFileAppender, as it zips up old log files. The file is 
available from:
http://mail-archives.apache.org/mod_mbox/logging-log4j-user/200405.mbox/%
3C5684A7E6FB10504393A2806C1F4C021003B0DC50@orion.qas.com%3E

The exact excexption that we see is pasted below. This stack keeps repeating 
several hundreds of times.
java.lang.StackOverflowError
    at java.io.IOException.<init>(IOException.java:40)
    at java.io.FileOutputStream.writeBytes(Native Method)
    at java.io.FileOutputStream.write(FileOutputStream.java:260)
    at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:336)
    at sun.nio.cs.StreamEncoder$CharsetSE.implWrite(StreamEncoder.java:395)
    at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:136)
    at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:146)
    at java.io.OutputStreamWriter.write(OutputStreamWriter.java:204)
    at java.io.Writer.write(Writer.java:126)
    at org.apache.log4j.helpers.QuietWriter.write(QuietWriter.java:47)
    at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:301)
    at com.csfb.fao.carat.util.file.ArchivedDailyRollingFileAppender.subAppend
(ArchivedDailyRollingFileAppender.java:375)
    at org.apache.log4j.WriterAppender.append(WriterAppender.java:159)
    at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:230)
    at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders
(AppenderAttachableImpl.java:65)
    at org.apache.log4j.Category.callAppenders(Category.java:203)
    at org.apache.log4j.Category.forcedLog(Category.java:388)
    at org.apache.log4j.Category.log(Category.java:835)
    at com.csfb.fao.carat.util.file.LoggingOutputStream.flush
(LoggingOutputStream.java:197)
    
    at java.io.PrintStream.write(PrintStream.java:260)
    at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:336)
    at sun.nio.cs.StreamEncoder$CharsetSE.implWrite(StreamEncoder.java:395)
    at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:136)
    at java.io.OutputStreamWriter.write(OutputStreamWriter.java:191)
    at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:111)
    at java.io.BufferedWriter.write(BufferedWriter.java:206)
    at java.io.Writer.write(Writer.java:126)
    at java.io.PrintStream.write(PrintStream.java:303)
    at java.io.PrintStream.print(PrintStream.java:448)
    at java.io.PrintStream.println(PrintStream.java:585)
    at org.apache.log4j.helpers.LogLog.error(LogLog.java:142)
    at org.apache.log4j.helpers.OnlyOnceErrorHandler.error
(OnlyOnceErrorHandler.java:77)
    at org.apache.log4j.helpers.OnlyOnceErrorHandler.error
(OnlyOnceErrorHandler.java:67)
    at org.apache.log4j.helpers.QuietWriter.write(QuietWriter.java:49)
    at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:301)
    at com.csfb.fao.carat.util.file.ArchivedDailyRollingFileAppender.subAppend
(ArchivedDailyRollingFileAppender.java:375)
    at org.apache.log4j.WriterAppender.append(WriterAppender.java:159)
    at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:230)
    at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders
(AppenderAttachableImpl.java:65)
    at org.apache.log4j.Category.callAppenders(Category.java:203)
    at org.apache.log4j.Category.forcedLog(Category.java:388)
    at org.apache.log4j.Category.log(Category.java:835)
    at com.csfb.fao.carat.util.file.LoggingOutputStream.flush
(LoggingOutputStream.java:197)

Thanks for your help.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


DO NOT REPLY [Bug 42151] - StackOverFlow in flush() method of LoggingOutputStream

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42151>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42151





------- Additional Comments From mayank.rao@credit-suisse.com  2007-04-17 23:40 -------
Created an attachment (id=19985)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=19985&action=view)
This is the file that contains the flush() method with the StackOverFlow


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


DO NOT REPLY [Bug 42151] - StackOverFlow in flush() method of LoggingOutputStream

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42151>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42151





------- Additional Comments From mayank.rao@credit-suisse.com  2007-04-17 23:38 -------
Created an attachment (id=19983)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=19983&action=view)
Exception trace

This is the exact exception trace that we see.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


DO NOT REPLY [Bug 42151] - StackOverFlow in flush() method of LoggingOutputStream

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42151>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42151


carnold@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




------- Additional Comments From carnold@apache.org  2007-04-18 08:02 -------
>From the stack trace it appears that you are using com.csfb.fao.carat.util.file.LoggingOutputStream to 
redirect System.err to log4j.  The ArchivedDailyRollingFileAppender has an IOException while trying to 
write to an file output stream which results in a diagnostic message being written to System.err, which 
causes another IOException and that repeats until stack space is exhausted.  You could likely repeat 
this on your dev environment if you can manufacture an IOException on your log file (plug the cable on 
an external drive, disconnect a network drive, etc).

Don't know what the triggering IOException is, but you could break the endless recursion by having the 
LoggingOutputStream check if the message starts with "log4j:" and if it does, then do something else 
with it other than feed it back to log4j.

Marking this as invalid since the problem can be fixed in LoggerOutputStream.



-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


DO NOT REPLY [Bug 42151] - StackOverFlow in flush() method of LoggingOutputStream

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42151>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42151


mayank.rao@credit-suisse.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |CLOSED




------- Additional Comments From mayank.rao@credit-suisse.com  2007-04-19 18:45 -------
(In reply to comment #4)
> From the stack trace it appears that you are using 
com.csfb.fao.carat.util.file.LoggingOutputStream to 
> redirect System.err to log4j.  The ArchivedDailyRollingFileAppender has an 
IOException while trying to 
> write to an file output stream which results in a diagnostic message being 
written to System.err, which 
> causes another IOException and that repeats until stack space is exhausted.  
You could likely repeat 
> this on your dev environment if you can manufacture an IOException on your 
log file (plug the cable on 
> an external drive, disconnect a network drive, etc).
> Don't know what the triggering IOException is, but you could break the 
endless recursion by having the 
> LoggingOutputStream check if the message starts with "log4j:" and if it does, 
then do something else 
> with it other than feed it back to log4j.
> Marking this as invalid since the problem can be fixed in LoggerOutputStream.

(In reply to comment #4)

Thanks, this seems to have resolved it!
> From the stack trace it appears that you are using 
com.csfb.fao.carat.util.file.LoggingOutputStream to 
> redirect System.err to log4j.  The ArchivedDailyRollingFileAppender has an 
IOException while trying to 
> write to an file output stream which results in a diagnostic message being 
written to System.err, which 
> causes another IOException and that repeats until stack space is exhausted.  
You could likely repeat 
> this on your dev environment if you can manufacture an IOException on your 
log file (plug the cable on 
> an external drive, disconnect a network drive, etc).
> Don't know what the triggering IOException is, but you could break the 
endless recursion by having the 
> LoggingOutputStream check if the message starts with "log4j:" and if it does, 
then do something else 
> with it other than feed it back to log4j.
> Marking this as invalid since the problem can be fixed in LoggerOutputStream.



-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


DO NOT REPLY [Bug 42151] - StackOverFlow in flush() method of LoggingOutputStream

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42151>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42151





------- Additional Comments From mayank.rao@credit-suisse.com  2007-04-17 23:39 -------
Created an attachment (id=19984)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=19984&action=view)
Appender being used.

This is the appender that we downloaded from the Log4j forums.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org