2016-11-18 117 views
0

我一直在试图(和失败)让logstash与log4j SocketAppender一起工作。logstash不能通过SocketAppender与log4j一起工作

这里是我的log4j.properties:

log4j.appender.tcp=org.apache.log4j.net.SocketAppender 
log4j.appender.tcp.Port=4560 
log4j.appender.tcp.RemoteHost=localhost 
log4j.appender.tcp.ReconnectionDelay=10000 
log4j.appender.tcp.Application=playground 

logstash.conf

input { 
    log4j { 
    } 
} 
output { 
    stdout {} 
} 

我已经设置logstash日志记录级别来跟踪和发送日志消息给它。之后,我在logstash的控制台日志中发现以下行:

11:44:35.778 [Ruby-0-Thread-21: c:/_work/issues/log4j_socketappender/logstash-5.0.1/vendor/bundle/jruby/1.9/gems/logstash-input-log4j-3.0.3-java/lib/logstash/inputs/log4j.rb:155] DEBUG logstash.inputs.log4j - Accepted connection {:client=>"127.0.0.1:61823", :server=>"0.0.0.0:4560"} 
11:44:35.795 [Ruby-0-Thread-21: c:/_work/issues/log4j_socketappender/logstash-5.0.1/vendor/bundle/jruby/1.9/gems/logstash-input-log4j-3.0.3-java/lib/logstash/inputs/log4j.rb:155] DEBUG logstash.inputs.log4j - Closing connection {:client=>"127.0.0.1:61823", :exception=>#<IOError: org.apache.log4j.spi.LoggingEvent; class invalid for deserialization>} 

任何帮助都非常感谢。

回答

2

这是一个错误。有一种变通方法:

找到文件logstash-core/lib/jars.rb在Logstash安装目录,注释掉以下行:

require_jar('org.apache.logging.log4j', 'log4j-1.2-api', '2.6.2') 

讨论在这里:GitHub Issue