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 Oscar Inostroza <o_...@yahoo.ca> on 2005/01/09 23:03:28 UTC

FallbackErrorHandler configuration

Hi,

I am trying to configure a fallbackError handler using SocketAppender.
My "PRIMARY" socket appender on localhost port 4560 contains an error 
handler that defines a "FALLBACK" socket appender on localhost port 6045.

When I test with my both log servers running (the one on port 4560 and 
the other on port 6045) all the log events are successfully logged in 
the primary log server on port 4560.

Now when I try to test the fallback functionality by stopping the 
primary log server on port 4560. No log events are logged at all in the 
fallback log server. As a side info my application is a servlet running 
on Tomcat and the stdout.log in tomcat shows an exception logged by 
log4j that was unable to connect to the primary log server, this tells 
my that log4j caught the fact that the primary server is down but yet is 
not sending any log to the fallback server.

I wonder what is wrong in my configuration file (attached below)
Help would be appreciated
Thanks,
Oscar

   <appender name="PRIMARY" class="org.apache.log4j.net.SocketAppender">
     <errorHandler class="org.apache.log4j.varia.FallbackErrorHandler">
       <root-ref/>
       <logger-ref ref="Log_debug"/>
       <logger-ref ref="Log_error"/>
       <appender-ref ref="FALLBACK"/>
     </errorHandler>
     <param name="RemoteHost" value="localhost"/>
     <param name="Port" value="4560"/>
     <param name="ReconnectionDelay" value="5000"/>
   </appender>

   <appender name="FALLBACK" class="org.apache.log4j.net.SocketAppender">
     <param name="RemoteHost" value="localhost"/>
     <param name="Port" value="6045"/>
     <param name="ReconnectionDelay" value="5000"/>	
   </appender>

   <logger name="Log_debug" additivity="false">
     <level value="debug"/>
     <appender-ref ref="PRIMARY"/>
   </logger>

   <logger name="Log_error" additivity="false">
     <level value="ALL"/>
     <appender-ref ref="PRIMARY"/>
   </logger>

   <root>
     <level value="ALL" />
     <appender-ref ref="PRIMARY"/>
   </root>

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


Re: FallbackErrorHandler configuration

Posted by Oscar Inostroza <o_...@yahoo.ca>.
Ohh, I see what you are suggesting.

Modifying the socket connector thread in the
SocketAppender.java specifically the run() method.
I assume that is what you are referring to.

That would work way better.

Thanks,
Oscar

 --- Ceki G�lc� <ce...@qos.ch> wrote: 
> At 08:12 PM 1/10/2005, Oscar Inostroza wrote:
> >Thanks for the prompt answer Ceki,
> >
> >I really enjoyed reading your book, I used log4j in
> >the past but I didn't realize until I read your
> book
> >that log4j offers a lot of functionality that I
> wasn't
> >aware of.
> 
> Thank you. I am glad you enjoyed reading it.
> 
> >Well it's good to know that the ErrorHandler will
> not
> >be supported in future log4j releases. I guess that
> >leaves me with no failover provided by log4j.
> >
> >An option would be to implement a fallback socket
> >appender and modifying my application to test the
> >connection to the log server before every single
> log
> >event. This will provide failover and fallback at
> >runtime (which is what I precisly want) but on the
> >other hand this will not be efficient at all and
> will
> >slow down the application in general.
> >
> >Do you have any advice on how to implement failover
> >using log4j Socket appenders?
> 
> SocketAppender already implements one kind of error
> recovery
> strategy. If a connection to the server host is
> down, it will try to
> reconnect every 30 seconds. You can tweak this
> period with the
> setReconnectionDelay option.
> 
> If you have two servers running, a primary and a
> secondary. You can
> modify SocketAppender to connect to the primary
> server, and if that
> fails, try the secondary. Just have a look at the
> code. The
> enhancement should not be too difficult to do.
> 
> 
> >Thanks again,
> >Oscar
> 
> -- 
> Ceki G�lc�
> 
>    The complete log4j manual:
> http://www.qos.ch/log4j/
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail:
> log4j-user-help@logging.apache.org
> 
>  

=====
Oscar

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca

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


Re: FallbackErrorHandler configuration

Posted by Ceki Gülcü <ce...@qos.ch>.
At 08:12 PM 1/10/2005, Oscar Inostroza wrote:
>Thanks for the prompt answer Ceki,
>
>I really enjoyed reading your book, I used log4j in
>the past but I didn't realize until I read your book
>that log4j offers a lot of functionality that I wasn't
>aware of.

Thank you. I am glad you enjoyed reading it.

>Well it's good to know that the ErrorHandler will not
>be supported in future log4j releases. I guess that
>leaves me with no failover provided by log4j.
>
>An option would be to implement a fallback socket
>appender and modifying my application to test the
>connection to the log server before every single log
>event. This will provide failover and fallback at
>runtime (which is what I precisly want) but on the
>other hand this will not be efficient at all and will
>slow down the application in general.
>
>Do you have any advice on how to implement failover
>using log4j Socket appenders?

SocketAppender already implements one kind of error recovery
strategy. If a connection to the server host is down, it will try to
reconnect every 30 seconds. You can tweak this period with the
setReconnectionDelay option.

If you have two servers running, a primary and a secondary. You can
modify SocketAppender to connect to the primary server, and if that
fails, try the secondary. Just have a look at the code. The
enhancement should not be too difficult to do.


>Thanks again,
>Oscar

-- 
Ceki Gülcü

   The complete log4j manual: http://www.qos.ch/log4j/



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


Re: FallbackErrorHandler configuration

Posted by Oscar Inostroza <o_...@yahoo.ca>.
Thanks for the prompt answer Ceki,

I really enjoyed reading your book, I used log4j in
the past but I didn't realize until I read your book
that log4j offers a lot of functionality that I wasn't
aware of.

Well it's good to know that the ErrorHandler will not
be supported in future log4j releases. I guess that
leaves me with no failover provided by log4j. 

An option would be to implement a fallback socket
appender and modifying my application to test the
connection to the log server before every single log
event. This will provide failover and fallback at
runtime (which is what I precisly want) but on the
other hand this will not be efficient at all and will
slow down the application in general. 

Do you have any advice on how to implement failover
using log4j Socket appenders?

Thanks again,
Oscar

 --- Ceki G�lc� <ce...@qos.ch> wrote: 
> Oscar,
> 
> Your config file looks correct. SocketAppender has
> not been tested to work 
> with FallbackErrorHandler. Moreover, given the
> extreme difficulty in 
> testing generic error handlers, log4j 1.3 no longer
> supports ErrorHandlers.
> 
> At 11:03 PM 1/9/2005, Oscar Inostroza wrote:
> >Hi,
> >
> >I am trying to configure a fallbackError handler
> using SocketAppender.
> >My "PRIMARY" socket appender on localhost port 4560
> contains an error 
> >handler that defines a "FALLBACK" socket appender
> on localhost port 6045.
> >
> >When I test with my both log servers running (the
> one on port 4560 and the 
> >other on port 6045) all the log events are
> successfully logged in the 
> >primary log server on port 4560.
> >
> >Now when I try to test the fallback functionality
> by stopping the primary 
> >log server on port 4560. No log events are logged
> at all in the fallback 
> >log server. As a side info my application is a
> servlet running on Tomcat 
> >and the stdout.log in tomcat shows an exception
> logged by log4j that was 
> >unable to connect to the primary log server, this
> tells my that log4j 
> >caught the fact that the primary server is down but
> yet is not sending any 
> >log to the fallback server.
> >
> >I wonder what is wrong in my configuration file
> (attached below)
> >Help would be appreciated
> >Thanks,
> >Oscar
> >
> >   <appender name="PRIMARY"
> class="org.apache.log4j.net.SocketAppender">
> >     <errorHandler
> class="org.apache.log4j.varia.FallbackErrorHandler">
> >       <root-ref/>
> >       <logger-ref ref="Log_debug"/>
> >       <logger-ref ref="Log_error"/>
> >       <appender-ref ref="FALLBACK"/>
> >     </errorHandler>
> >     <param name="RemoteHost" value="localhost"/>
> >     <param name="Port" value="4560"/>
> >     <param name="ReconnectionDelay" value="5000"/>
> >   </appender>
> >
> >   <appender name="FALLBACK"
> class="org.apache.log4j.net.SocketAppender">
> >     <param name="RemoteHost" value="localhost"/>
> >     <param name="Port" value="6045"/>
> >     <param name="ReconnectionDelay" value="5000"/>
> >   </appender>
> >
> >   <logger name="Log_debug" additivity="false">
> >     <level value="debug"/>
> >     <appender-ref ref="PRIMARY"/>
> >   </logger>
> >
> >   <logger name="Log_error" additivity="false">
> >     <level value="ALL"/>
> >     <appender-ref ref="PRIMARY"/>
> >   </logger>
> >
> >   <root>
> >     <level value="ALL" />
> >     <appender-ref ref="PRIMARY"/>
> >   </root>
> >
>
>---------------------------------------------------------------------
> >To unsubscribe, e-mail:
> log4j-user-unsubscribe@logging.apache.org
> >For additional commands, e-mail:
> log4j-user-help@logging.apache.org
> 
> -- 
> Ceki G�lc�
> 
>    The complete log4j manual:
> http://www.qos.ch/log4j/
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail:
> log4j-user-help@logging.apache.org
> 
>  

=====
Oscar

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca

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


Re: FallbackErrorHandler configuration

Posted by Ceki Gülcü <ce...@qos.ch>.
Oscar,

Your config file looks correct. SocketAppender has not been tested to work 
with FallbackErrorHandler. Moreover, given the extreme difficulty in 
testing generic error handlers, log4j 1.3 no longer supports ErrorHandlers.

At 11:03 PM 1/9/2005, Oscar Inostroza wrote:
>Hi,
>
>I am trying to configure a fallbackError handler using SocketAppender.
>My "PRIMARY" socket appender on localhost port 4560 contains an error 
>handler that defines a "FALLBACK" socket appender on localhost port 6045.
>
>When I test with my both log servers running (the one on port 4560 and the 
>other on port 6045) all the log events are successfully logged in the 
>primary log server on port 4560.
>
>Now when I try to test the fallback functionality by stopping the primary 
>log server on port 4560. No log events are logged at all in the fallback 
>log server. As a side info my application is a servlet running on Tomcat 
>and the stdout.log in tomcat shows an exception logged by log4j that was 
>unable to connect to the primary log server, this tells my that log4j 
>caught the fact that the primary server is down but yet is not sending any 
>log to the fallback server.
>
>I wonder what is wrong in my configuration file (attached below)
>Help would be appreciated
>Thanks,
>Oscar
>
>   <appender name="PRIMARY" class="org.apache.log4j.net.SocketAppender">
>     <errorHandler class="org.apache.log4j.varia.FallbackErrorHandler">
>       <root-ref/>
>       <logger-ref ref="Log_debug"/>
>       <logger-ref ref="Log_error"/>
>       <appender-ref ref="FALLBACK"/>
>     </errorHandler>
>     <param name="RemoteHost" value="localhost"/>
>     <param name="Port" value="4560"/>
>     <param name="ReconnectionDelay" value="5000"/>
>   </appender>
>
>   <appender name="FALLBACK" class="org.apache.log4j.net.SocketAppender">
>     <param name="RemoteHost" value="localhost"/>
>     <param name="Port" value="6045"/>
>     <param name="ReconnectionDelay" value="5000"/>
>   </appender>
>
>   <logger name="Log_debug" additivity="false">
>     <level value="debug"/>
>     <appender-ref ref="PRIMARY"/>
>   </logger>
>
>   <logger name="Log_error" additivity="false">
>     <level value="ALL"/>
>     <appender-ref ref="PRIMARY"/>
>   </logger>
>
>   <root>
>     <level value="ALL" />
>     <appender-ref ref="PRIMARY"/>
>   </root>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-user-help@logging.apache.org

-- 
Ceki Gülcü

   The complete log4j manual: http://www.qos.ch/log4j/



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