启用S​​SL的log4j2套接字Appender

时间:2018-11-22 13:39:16

标签: log4j2

这是我的使用SSL配置的log4j2 SocketAppender

<Configuration status="warn">
<Socket name="transSocketAppender" host="lxddv002.test.intranet"
port="9400" protocol="TCP" reconnectionDelayMillis="30000"
immediateFail="false">
    <PatternLayout pattern="%m%n" charset="UTF-8" />
    <SSL>
        <Truststore location="C:\Users\AC26252\Desktop\certs\keystore.jks"
            password="123456" />
    </SSL>
</Socket>

<Async name="transSocketAsyncAppender" bufferSize="204800">
    <AppenderRef ref="transSocketAppender" />
</Async>

服务器重新启动时出现此错误,并且前几(2或3)个请求日志丢失并且没有被传输。

2018-11-22 19:04:05,243 AsyncAppender-socketAsyncAppender ERROR Unable to write to stream TLS:lxddv002.test.intranet:9400 for appender socketAppender: org.apache.logging.log4j.core.appender.AppenderLoggingException: Error writing to TLS:lxddv002.test.intranet:9400
2018-11-22 19:04:05,259 AsyncAppender-socketAsyncAppender ERROR An exception occurred processing Appender socketAppender
org.apache.logging.log4j.core.appender.AppenderLoggingException: Error writing to TLS:lxddv002.test.intranet:9400
at org.apache.logging.log4j.core.net.TcpSocketManager.write(TcpSocketManager.java:229)`at org.apache.logging.log4j.core.appender.OutputStreamManager.write(OutputStreamManager.java:201)`

我的配置有问题吗?任何帮助表示赞赏。谢谢

1 个答案:

答案 0 :(得分:0)

问题出在我的log4j2版本上。我已经升级到最新版本,并且现在可以正常工作。