logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francesco Russo <f.ru...@cineca.it>
Subject Re: Need FallbackErrorHandler Example
Date Tue, 28 Sep 2004 12:55:31 GMT
Hi Ken,
in order to properly use the FallbackErrorHandler you should configure 
your appenders in the following way:

--------------------------------------------------------------------
<appender namebackup.appender" class="...">
   ...
</appender>

<appender name="foo.appender" class="...">
   <errorHandler class="org.apache.log4j.varia.FallbackErrorHandler">
     <logger-ref ref="foo.logger"/>
     <appender-ref ref="backup.appender"/>
   </errorHandler>
   ...
</appender>

<logger name="foo.logger"...>
--------------------------------------------------------------------

In the sample above the logger foo.logger is supposed to use the 
appender foo.appender and foo.appender is told to use the 
backup.appender in case of error. Pay attention to the <logger-ref> 
element: it has to "point to" the logger that is currently using that 
appender. The <appender-ref> element defines which is the appender to be 
used in case of need.

Hope this helps,

-- 
______________________________________________________
Francesco Russo
CINECA - Interuniversitary Computing Centre
http://www.cineca.it
via Magnanelli, 6/3
40033 Casalecchio di Reno (Bologna) - ITALY
e-mail: f.russo@cineca.it
Phone: +39 051 6171 775



Ken Baltrinic wrote:
> I am confused. Implement my own appender?  Isn't that the purpose of the FallbackErrorHandler
is to do this for me?
> 
> The JavaDocs for the class state:
> 
> 
>>The FallbackErrorHandler implements the ErrorHandler interface such that a 
>>secondary appender may be specified. This secondary appender takes over if 
>>the primary appender fails for whatever reason.
> 
> 
> Can anyone help with this? Anyone want to lend me a copy of Ceki Gülcü's Book? :-)
 Sell me a used copy? :-)
> 
> --Ken
> 
> -----Original Message-----
> From: Ivan Jouikov [mailto:ivan@ablogic.net] 
> Sent: Tuesday, September 28, 2004 12:27 AM
> To: 'Log4J Users List'
> Subject: RE: Need FallbackErrorHandler Example
> 
> My only thought is creating your own appender, which would wrap both JDBC and file appenders,
and try to instantiate one, and if it wails - try to instantiate the other.
> 
> 
>>-----Original Message-----
>>From: Ken Baltrinic [mailto:ken.baltrinic@inforeliance.com]
>>Sent: Monday, September 27, 2004 5:15 PM
>>To: Log4J Users List
>>Subject: Need FallbackErrorHandler Example
>>
>>I am trying to setup log4j to use a FileAppender as a fall back appender
>>for a JDBCAppender.  Are there some examples or documentation I could
>>look at?
>>
>>
>>
>>I took a crack at it but I am getting the warning: log4j:WARN Failed to
>>set property [backupAppender] to value "LocalFileAppender".
>>
>>
>>
>>The relevant xml snippet look like this:
>>
>>
>>
>>  <appender name="LocalFileAppender"
>>class="org.apache.log4j.FileAppender">
>>
>>    <param name="file"
>>value="C:\\Sun\\AppServer\\domains\\domain1\\logs\\logging-output.xml"/>
>>
>>    <layout class="org.apache.log4j.xml.XMLLayout"/>
>>
>>  </appender>
>>
>>
>>
>>
>>
>>  <appender name="JDBCAppender"
>>class="org.apache.log4j.jdbcplus.JDBCAppender">
>>
>>
>>
>>    <errorHandler class="org.apache.log4j.varia.FallbackErrorHandler">
>>
>>      <param name="BackupAppender" value="LocalFileAppender"/>
>>
>>    </errorHandler>
>>
>>
>>
>>            . . .
>>
>>
>>
>>  </appender>
>>
>>
>>
>>
>>
>>Thanks for help,
>>
>>--Ken
>>
>>
>>---
>>Outgoing mail is certified Virus Free.
>>Checked by AVG anti-virus system (http://www.grisoft.com).
>>Version: 6.0.766 / Virus Database: 513 - Release Date: 17.09.2004
>>
>>
>>
>>---
>>Incoming mail is certified Virus Free.
>>Checked by AVG anti-virus system (http://www.grisoft.com).
>>Version: 6.0.766 / Virus Database: 513 - Release Date: 17.09.2004
>>
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.766 / Virus Database: 513 - Release Date: 17.09.2004
>  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message