I saw that before, but we can't lose any message, so if you have a broken pipe, the message is gone! I can send my solution if any of you are interested!!
Thanks, Gui On Thu, Jan 15, 2009 at 4:53 PM, Maarten Bosteels <[email protected]>wrote: > I have written an AsyncSocketAppender (but I don't have the code right > here). > > It's really not hard to implement when you use the Java 5 Executor > framework. > But you have to decide what to do when the queue becomes too big. > > One option is to discard messages (ThreadPoolExecutor.DiscardOldestPolicy) > another option is > to use a fallbackAppender : as long as the connection is broken you send > all > events to a FileAppender. > > My goal is to create a small open-source library with an > AsyncSocketAppender > for both log4j and logback that uses a pluggable encoder (similar to a > Layout but for writing an event to an OutputStream instead of generating a > String) > > And providing a set of different encoders, eg using > (a) java serialization > (b) xml > (c) protobuf [1] > (d) Apache Thrift [2] > > Of course with corresponding receivers and a nice GUI :-) > > Alternative: > I haven't tried it myself but maybe you can wrap an SocketAppender in an > AsyncAppender [3] to achieve what you want. > > [1] http://code.google.com/p/protobuf/ > [2] http://incubator.apache.org/thrift/ > [3] > > http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/AsyncAppender.html > > Regards, > Maarten > > > On Wed, Jan 14, 2009 at 1:36 PM, <[email protected]> wrote: > > > I guess you will be looking for > > > http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/net/JMSAppender.html > > > > > > > > ________________________________ > > From: Guilherme Costa <[email protected]> > > To: Log4J Users List <[email protected]> > > Sent: Wednesday, 14 January, 2009 12:11:15 > > Subject: SocketAppender > > > > I saw the code for that appender (thanks Open Source) and I noticed that > if > > the socket is not connected when a new message comes, the log message is > > lost. > > There are any appender out there that implements queue? We currently have > a > > logging system, home made. Very simple, it only sends a string message, > the > > application ID and the client IP address, but it has this queue to > prevent > > losing any message. My boss, that is fighting against the log4j idea told > > me > > that if we don't have a queue, we will keep using the same old logging > > system (really old, maybe 6 years old!!). > > > > If there are no Appender that implements a queue, I will have to write > one > > for out application. > > > > > > Thanks, > > Gui > > > > > > > > > > >
