You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Kevin Steppe <ks...@pacbell.net> on 2001/01/27 00:05:34 UTC

Error reporting from inside an Appender

I was looking at FileAppender for an example of how to report errors
from inside an
Appender.  Sometimes it calls errorHandler.error(...) and sometimes
LogLog.error(...).  Could someone explain the method in this madness?

Kevin





Re: Error reporting from inside an Appender

Posted by Kevin Steppe <ks...@pacbell.net>.
I don't agree that one case justifies a different handling.  I'll just use the
ErrorHandler if my JDBCAppender throws an SQLException.

Thank you for the explanation,
Kevin


Ceki Gülcü wrote:

> Kevin,
>
> In the latest log4j release (1.0.4), the FileAppender consistently uses its
> errorHandler to report errors. It uses LogLog.error only once within the
> closeWriterIfOurs method. This method is copied below:
>
>    /**
>       Close this.writer if opened by setFile or FileAppend(filename..)
>    */
>    protected
>    void closeWriterIfOurs() {
>      if(this.qwIsOurs && this.qw != null) {
>        try {
>             this.qw.close();
>        }
>        catch(java.io.IOException e) {
>          LogLog.error("Could not close output stream " + qw, e);
>        }
>      }
>    }
>
> The rationale being that the user probably does not want to trigger a
> possibly heavy error handling mechanism in case of an error while closing a
> java.io.Writer. This is perhaps too smart an approach to do good. However,
> I would hardly call it *madness*. I hope that this makes better sense. Ceki
>
> At 15:05 26.01.2001 -0800, you wrote:
> >I was looking at FileAppender for an example of how to report errors
> >from inside an
> >Appender.  Sometimes it calls errorHandler.error(...) and sometimes
> >LogLog.error(...).  Could someone explain the method in this madness?
> >
> >Kevin
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>
> ----
> Ceki Gülcü - Independent IT Consultant
>
> av. de Rumine 5            Tel: ++41 21 351 23 15
> CH-1005 Lausanne        e-mail: cgu@urbanet.ch  or
> Switzerland                     ceki_gulcu@yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Re: Error reporting from inside an Appender

Posted by Ceki Gülcü <cg...@urbanet.ch>.
Kevin,

In the latest log4j release (1.0.4), the FileAppender consistently uses its 
errorHandler to report errors. It uses LogLog.error only once within the 
closeWriterIfOurs method. This method is copied below:


   /**
      Close this.writer if opened by setFile or FileAppend(filename..)
   */
   protected
   void closeWriterIfOurs() {
     if(this.qwIsOurs && this.qw != null) {
       try {
            this.qw.close();
       }
       catch(java.io.IOException e) {
         LogLog.error("Could not close output stream " + qw, e);
       }
     }
   }

The rationale being that the user probably does not want to trigger a 
possibly heavy error handling mechanism in case of an error while closing a 
java.io.Writer. This is perhaps too smart an approach to do good. However, 
I would hardly call it *madness*. I hope that this makes better sense. Ceki


At 15:05 26.01.2001 -0800, you wrote:
>I was looking at FileAppender for an example of how to report errors
>from inside an
>Appender.  Sometimes it calls errorHandler.error(...) and sometimes
>LogLog.error(...).  Could someone explain the method in this madness?
>
>Kevin
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org

----
Ceki Gülcü - Independent IT Consultant

av. de Rumine 5            Tel: ++41 21 351 23 15
CH-1005 Lausanne        e-mail: cgu@urbanet.ch  or
Switzerland                     ceki_gulcu@yahoo.com