You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Paul Smith <Pa...@lawlex.com.au> on 2004/05/25 01:58:30 UTC

RE: reconnecting to SocketHubAppender

> Still nice to be able to have the Receiver itself have a 
> reconnect ability,
> but the above was quicker for me at the time.

I've had a very brief look at how this might be accomplished.  It appears
that once the java.net.Socket instance has been created, I cannot see a way
to 'trap' when the Socket connection is broken.  There _are_ some methods on
the Socket class, isClosed, isConnected, which could help by periodic
inspection, however these have only been added since JDK 1.4.

I guess I could change the Receiver class so they can have this detection
code using reflection to detect if the methods are available, but I thought
I would check with the group on this first.

Does anyone else have a suggestion here?

cheers,

Paul Smith

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


RE: reconnecting to SocketHubAppender

Posted by Steve Mactaggart <st...@golftime.com.au>.
Just shooting from the hip, but when a message gets sent, I assume it throws
an exception if not connected, could you catch that exception and attempt to
re-connect..

It means that the connection can break, but is not re-connected until the
next message heads out that way.

Not sure, just thinking out loud.

Steve 

> -----Original Message-----
> From: Paul Smith [mailto:Paul.Smith@lawlex.com.au] 
> Sent: Tuesday, 25 May 2004 9:59 AM
> To: 'log4j-dev@logging.apache.org'
> Subject: RE: reconnecting to SocketHubAppender
> 
> > Still nice to be able to have the Receiver itself have a 
> > reconnect ability,
> > but the above was quicker for me at the time.
> 
> I've had a very brief look at how this might be accomplished. 
>  It appears
> that once the java.net.Socket instance has been created, I 
> cannot see a way
> to 'trap' when the Socket connection is broken.  There _are_ 
> some methods on
> the Socket class, isClosed, isConnected, which could help by periodic
> inspection, however these have only been added since JDK 1.4.
> 
> I guess I could change the Receiver class so they can have 
> this detection
> code using reflection to detect if the methods are available, 
> but I thought
> I would check with the group on this first.
> 
> Does anyone else have a suggestion here?
> 
> cheers,
> 
> Paul Smith
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org


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