jurmous / logstash-log4j2

Log4j2 plugin for logstash
41 stars 21 forks source link

Async wrapping Socket appender generate 'Broken Pipe' exception #3

Closed ayashjorden closed 10 years ago

ayashjorden commented 10 years ago

Hi Jurmous,

First I'd like to say that the plugin is GREAT! and easy to use.

The issue occurs when I wrap log4j2-Socket appender with an Async appender.

For some reason the connection gets closed.

My Log4 config is:

<Appenders>
    <Socket name="socket_app" level="debug" host="localhost" port="8600">
        <SerializedLayout />
    </Socket>
    <Async name="asyncSocket" bufferSize="2048">
        <AppenderRef ref="socket_app"/>
    </Async>
</Appenders>
<Loggers>
    <Root level="debug">
        <AppenderRef ref="asyncSocket"/>
    </Root>
</Loggers>

my logstash config is:

input { log4j2 { host => localhost port => 8600 mode => server } } output { elasticsearch { host => localhost cluster => "es_test" index => "%{type}-%{+YYYY.MM.dd.HH}" }

}

I'm getting a SocketExcetoion - Broket Pipe.

I also tried with re-connection config and it seems that the connection is getting closed by logstash side.... When I remove the Async appender it works OK(slower, but OK).

The Async+Socket appender works well against a stand-alone log4j-TCPSocketServer instance

Any Ideas??

jurmous commented 10 years ago

Thanks! Although I must say it is mostly based on the logstash implementation of log4j input which I adapted for log4j2 changes.

The socket exceptions happen mostly because of parse exceptions in Logstash. Can you start logstash with --debug parameter and post the complete exception with stack trace which should show up in the debug output?

ayashjorden commented 10 years ago

Hi, Please see attached. (And thanks for the FAST reply :)

screenshot from 2014-07-21 15 16 08

ayashjorden commented 10 years ago

Also, Can you upgrade to log4j2 2.0? they released it few days ago....

jurmous commented 10 years ago

Are you on the latest release? Because I released a version 4 days ago which supports 2.0. Current release 3.1 is of 3 days ago: https://github.com/jurmous/logstash-log4j2/releases

ayashjorden commented 10 years ago

Hi, Tried with latest version, but the broken-pipe is still happening.

Finally I found a work-around: removed Async appender and use the socket appender inside an 'asyncRoot' element.

ayashjorden commented 10 years ago

Hi again, Unfortunately my workaround is causing message loss.

I've read some more on async logging in log4j-2 and they use LMAX Disruptor. Only when I use async loggers with "-DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector" I get the "SocketException: Broket pipe" exception.

When I start a standalone TcpSocketServer instance the socket appender(with the above setting) connects with no exceptions... Can you advise?

Thanks, Yarden

jurmous commented 10 years ago

Can you check out release 3.2 if it works for you? https://github.com/jurmous/logstash-log4j2/releases/

ayashjorden commented 10 years ago

Like a charm :+1:

I'll do some performance tests now...

jurmous commented 10 years ago

Thanks for testing!

Let me know what the results are :smile: