Bug 37638 - logging doesn't fall back with FallbackErrorHandler if PRIMARY appender is used by multiple loggers
logging doesn't fall back with FallbackErrorHandler if PRIMARY appender is us...
Status: NEW
Product: Log4j
Classification: Unclassified
Component: Other
1.2
PC Windows 2000
: P2 normal
: ---
Assigned To: log4j-dev
: ErrorMessage
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2005-11-25 15:05 UTC by Andrei Savitski
Modified: 2009-10-08 21:07 UTC (History)
0 users



Attachments
Test case that demonstrates problem with multiply attached fallbackerrorhandler (3.53 KB, patch)
2009-10-08 21:04 UTC, Curt Arnold
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrei Savitski 2005-11-25 15:05:45 UTC
With standart config from sample for FallbackErrorHandler everything works 
fine. But if you'll add anoher logger using PRIMARY appender, than nothing will 
appear in log file specified for backup appender.

Here is con file:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration debug="true" 
xmlns:log4j="http://jakarta.apache.org/log4j/">
  
  <appender name="PRIMARY" class="org.apache.log4j.FileAppender">
    <errorHandler class="org.apache.log4j.varia.FallbackErrorHandler">
      <root-ref/>
      <appender-ref ref="FALLBACK" />
    </errorHandler>
    <param name="File" value="xyz/z.log" />
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%-5p %c{2} - %m%n"/>
    </layout>
  </appender>

  <appender name="FALLBACK" class="org.apache.log4j.FileAppender">
    <param name="File" value="fallback.log" />
    <param name="Append" value="false" />
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="--%d %p %t %c - %m%n"/>
    </layout>
  </appender>

  <logger name="org.mailbox">
    <level value="warn" />
    <appender-ref ref="PRIMARY" />
  </logger>

  <root>
    <level value="debug" />
    <appender-ref ref="PRIMARY" />
  </root>

</log4j:configuration>

To reproduce bug, just make first log file readonly.
Comment 1 Curt Arnold 2009-10-08 21:04:39 UTC
Created attachment 24366 [details]
Test case that demonstrates problem with multiply attached fallbackerrorhandler
Comment 2 Curt Arnold 2009-10-08 21:07:24 UTC
The sample configuration only specifies falling back on the root logger.  If there was a failure, only the root logger would be switched to the FALLBACK appender.  The "org.mailbox" logger would keep the failed PRIMARY appender.

I've attached a test case that is a variant of the existing ErrorHandlerTestCase that should have worked, but at least for errors that occur during configuration, something closes FALLBACK appender before it can output anything.  Likely some unfortunately interaction between the configurator and the FallbackErrorHandler.