On Apr 14, 2008, at 12:26 PM, J.T. Conklin wrote:

Hi,

When an appender's doAppend method throws an exception, it unwinds
through the call stack.  At the very least, this means that the log
message won't be passed to any other appenders that might otherwise
process it.  It seems to me that log4cxx needs to protect calls to
doAppend with a try/catch(...) block that squelches the errant
exception.

In my case, the exception escaped all the way up to a ->log() call
from one of my destructors, which caused bad things to happen...

   --jtc

-- J.T. Conklin

I don't have time to explore at the moment (the US government has me on its annual April 15th deadline), however it is likely that you are seeing a design that is directly carried over from log4j. In general, log4cxx tries to maintain a very similar design to log4j, so if log4j doesn't have a try/catch block, then log4cxx would not. If there is not a try/catch block in log4j, then the "contract" with the appender is that it not throw an exception from its doAppend block. It would be good to know which of the following category your problem falls into:

1. You are using a custom appender that throws an exception. The log4cxx dispatching code does not catch the exception. The log4j and log4cxx dispatching logics are consistent. Resolution: catch the exception within your appender.

2. You are using a log4cxx provided appender that throws an exception where the log4j equivalent does not. The log4cxx dispatch code does not catch the exception. The log4j and log4cxx dispatching logics are consistent. Resolution: Fix the log4cxx appender.

3. You are using a log4cxx provided appender that throws an exception as does the log4j equivalent. The log4cxx dispatch code does not catch the exception, but the log4j dispatch code would. Resolution: Fix the log4cxx dispatch code.

4. You are using a log4cxx provided appender that throws an exception as does the log4j equivalent. Neither log4cxx and log4j catch the exception. Resolution: Find a resolution to the problem for log4j and then port to log4cxx.

Reply via email to