java – log4j:Socket Appender如何工作?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java – log4j:Socket Appender如何工作?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1360字,纯文字阅读大概需要2分钟。
内容图文
![java – log4j:Socket Appender如何工作?](/upload/InfoBanner/zyjiaocheng/700/4cf088d43a5b4bd19fa959b51a9ab1ed.jpg)
我不确定Socket Appender是如何工作的.我知道记录事件被发送到特定端口.然后我们可以在控制台上打印日志或将其放入文件中.
我的问题更多的是关于日志的发送方式.有没有,例如一个队列?是同步还是异步?可以使用它减慢我的程序?
我找到了一些信息here,但对我来说还不清楚.
解决方法:
从SocketAppender文档
Logging events are automatically buffered by the native TCP
implementation. This means that if the link to server is slow but
still faster than the rate of (log) event production by the client,
the client will not be affected by the slow network connection.
However, if the network connection is slower then the rate of event
production, then the client can only progress at the network rate. In
particular, if the network link to the the server is down, the client
will be blocked.On the other hand, if the network link is up, but the
server is down, the client will not be blocked when making log
requests but the log events will be lost due to server unavailability.
由于appender使用TCP协议,我会说日志事件是“同步的”.
基本上,appender使用TCP将第一个日志事件发送到服务器.但是,如果网络延迟太高以至于在生成第二个事件时仍未发送消息,则第二个日志事件将不得不等待(从而阻塞),直到第一个事件被消耗.所以是的,如果应用程序生成的日志事件比网络传递的速度快,则会降低应用程序的速度.
正如@Akhil和@Nikita所提到的,如果您不希望应用程序的性能受到网络延迟的影响,那么JMSAppender或AsyncAppender将是更好的选择.
内容总结
以上是互联网集市为您收集整理的java – log4j:Socket Appender如何工作?全部内容,希望文章能够帮你解决java – log4j:Socket Appender如何工作?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。