logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wullschleger, Donat" <Donat.Wullschle...@siemens.co.uk>
Subject RE: RollingFileAppender disk full handling
Date Thu, 01 Aug 2002 07:48:04 GMT
Colin,

I tried a similar thing with the DailyRollingFileAppender (or for test
purposes just with the FileAppender). My aim was to ask the user to replace
the media if it is full with a new one or choose another location for the
logfile. To detect an exception or another error condition, I did add a
custom errorhandler (as Kevin suggested). But I stumbled when I wanted to
close the logfile and open a new one afterwards - I just couldn't find a
solution as 'reset' and 'close' also close the logger (and not only the
file) and after calling these functions log4j issues errormessages on the
console...

If you get any further, I would appreciate to hearing from you. 

Donat

P.S. please find below a code fragment of how I added the custem
errorhandler (LogFileErrorHandler) to all FileAppenders.

// Add custom errorhandler to all FileAppenders
Enumeration eapp = LogManager.getRootLogger().getAllAppenders();
        
for (Enumeration e = eapp;e.hasMoreElements();) {
   Object obj = e.nextElement();
   if (obj instanceof FileAppender) {
       FileAppender fa = (FileAppender) obj;
       LogFileErrorHandler lfh = new LogFileErrorHandler();
       fa.setErrorHandler(lfh);
    }
}



-----Original Message-----
From: Kevin Steppe [mailto:ksteppe@pacbell.net]
Sent: Wednesday, July 31, 2002 9:35 PM
To: Log4J Users List
Subject: Re: RollingFileAppender disk full handling


Colin,
    log4j does not throw exceptions.  However, the RollingFileAppender 
-should- make calls to the errorHandler.  Implement your own 
ErrorHandler and you should be able to get those notifications.

Kevin


Colin MacDonald wrote:

>Hi all!  In my application, I need to know if log4j failed to write a log
>message.
>
>I'm using RollingFileAppender, and from looking at the source, it catches
>exceptions and just writes to console.  I'm writing transaction audit logs,
>so if I can't write to the log (disk full, or whatever) I want to abort the
>transaction.  Note that the log writing is done first; it doesn't need to
>part of an atomic transaction.
>
>First, is my reading of the code correct?  Will the code that calls log4j
>not get an exception?
>
>Second, any ideas on how to work around this?  Custom appender?  It seems
>like a waste to re-implement RollingFileAppender.
>
>Thanks for any help on this!
>
>-----------------------------------------------------------------
>Colin MacDonald  |  Software Developer  |  Templar Corporation  |
>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.380 / Virus Database: 213 - Release Date: 7/24/2002
>
>
>--
>To unsubscribe, e-mail:
<mailto:log4j-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail:
<mailto:log4j-user-help@jakarta.apache.org>
>
>



--
To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>


This communication contains information which is confidential and may be
legally privileged and is for the exclusive use of the addressee(s). If you
are not a named addressee please contact the sender immediately, and delete
the communication from your system. You are hereby notified that any
disclosure, distribution or copying of this communication, in whole or in
part, is strictly prohibited.  Any views or opinions presented are solely
those of the author and do not necessarily represent those of the Company,
its directors or officers unless otherwise specifically stated. The Company
is not responsible for any reliance placed on the information contained
herein and excludes all liability. Any information / data received by the
Company in this communication may be retained and used for business purposes
in accordance with the Data Protection Act 1998 and consent for the same
shall be deemed given, unless specifically stated otherwise. 

(c)Copyright 2002 Siemens Metering Limited All Rights Reserved. 

--
To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>


Mime
View raw message