Hi,
we have a requirement for several applications that if logging is
unavailable then the application should stop (after printing a message
to std err). The premise is that logging is an essential function so if
it's unavailable then the application should not proceed.

The standard log4j distribution doesn't do this. However, I've modified
log4j-1.1b7 to enable this.
Basically what I've done is:
1. In class LogLog:
a) added fatal(...) methods to log a message to std err and then
System.exit();
b) added stopOnError static boolean
c) modified error(...)  to check for stopOnError. If it's true then call
fatal()
d) Added methods to set/unset stopOnError

2. PropertyConfigurator
a) Added log4j.stopOnError property

3. DOMConfigurator
a) Added stoponError="true|false" attribute

With these modifications if LogLog.error() is called when stopOnError =
true then the application will stop.

A brief examination of the rest of log4J shows that this should work in
most situations where a non-recoverable error occurs. The default
ErrorHandler (OnlyOnceErrorHandler) invokes LogLog.error() to log the
error and so should work transparently.

My only concern would be if there are methods in some classes that use
LogLog.error() when they should be using LogLog.warn().

I considered the alternative of creating a speciall ErrorHandler class
but the problem with this is that not all methods use the errorhander.
Some just invoke LogLog.error() directly. Therefore, to use a special
ErrorHandler, all classes should be modified to use it rather than
LogLog.error().

Of course, there is also the issue of using System.exit(); the abort
should probably be done through an unchecked exception such as
java.lang.Error (or a special subclass of )

What thoughts are there on this?

Murray Knox


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to