gpt4 book ai didi

sockets - 使用 logback 的 SocketAppender 丢失日志条目

转载 作者:行者123 更新时间:2023-12-03 12:05:30 26 4
gpt4 key购买 nike

我正在使用 Logback SSLSocketAppender 将日志定向到中央记录器服务器。应用程序运行正常,我可以看到服务器端正在接收日志。

但是,仔细查看日志,通常每 5 个日志条目中,就有 1 或 2 个被丢弃。根据Logback Doc , TCP 协议(protocol)应该保证日志的最终一致性,但在我的情况下不是。

SocketAppender operates above the Transmission Control Protocol (TCP) layer which provides a reliable, sequenced, flow-controlled end-to-end octet stream. Consequently, if the remote server is reachable, then log events will eventually arrive there. Otherwise, if the remote server is down or unreachable, the logging events will simply be dropped. If and when the server comes back up, then event transmission will be resumed transparently. This transparent reconnection is performed by a connector thread which periodically attempts to connect to the server.



想知道以前有人遇到过类似的问题吗?

谢谢!

- - - 编辑 - - -

我做了一个实验来确认它:
int i = 0 ;
while (i < 10000) {
log.info(i + " : =======");
i ++;
}

在服务器端,收到的日志如下所示:
2013-09-12 17:59:09,174 INFO  [main]  - 0 : =======
2013-09-12 17:59:09,175 INFO [main] - 5 : =======
2013-09-12 17:59:09,175 INFO [main] - 10 : =======
2013-09-12 17:59:09,176 INFO [main] - 13 : =======
2013-09-12 17:59:09,177 INFO [main] - 17 : =======
2013-09-12 17:59:09,178 INFO [main] - 21 : =======

如果我再次尝试,记录的消息会有所不同。

最佳答案

http://logback.qos.ch/news.html声明 Logback 1.1.1 包含对与 SocketAppender 相关的丢弃事件的修复。

关于sockets - 使用 logback 的 SocketAppender 丢失日志条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18755255/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com