并发 log4j
我有自己的日志引擎,它将日志写入具有阻塞队列的单独线程上。为了使用“标准软件”,我正在考虑切换到 log4j。
我不希望我的高并发软件因日志命令而变慢,这些命令在调用命令时将所有内容写入磁盘。 log4j 可以用作垃圾箱吗?
I have my own logging engine which writes the logs on a separate thread with a blocking queue. For the sake of using "standard software" I am thinking about switching to log4j.
I don't want my highly concurrent software to be slowed down by log commands that write everything to disk as some as the command is called. Can log4j be used as a dumpster instead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Log4j 是大多数 JavaEE 应用程序服务器上的日志记录实现,因此这是对其并发能力的一个很好的广告。
话虽如此,我已经看到Log4j 1.2在高负载情况下出现死锁。一些调查凸显了源代码中一些可怕的糟糕同步。显然,这个问题在 Log4j 1.3 中得到了修复,尽管这方面的开发已经放缓或完全停止——我感觉大部分源代码都无法挽救。
但是,如果您可以自由选择,那么您应该考虑 Logback,它是 Log4j 的精神继承者。这是彻底的重新设计,可能对您来说是更好的选择。
Log4j is the logging implementation on most JavaEE app-servers out there, so that's a good advert for its concurrency abilities.
Having said that, I have seen Log4j 1.2 deadlock under high load conditions. A bit of investigation highlighted some scarily bad synchronization in the source code. Apparently, this was fixed in Log4j 1.3, although development on this has slowed or stopped altogether - I get the feeling much of the source was unsalvageable.
However, if you're free to choose, then you should consider Logback instead, the spiritual successor to Log4j. It's a ground-up redesign, and is probably a better option for you.
查看log4j的异步appender,它缓冲日志消息广告使用单独的线程将它们传递给附加程序。您可能认为 log4j 异步附加程序不合适 (这里有一些关于它的抱怨),你总是可以制作自己的附加程序。
Check out log4j's asynchronous appender, it buffers log messages ad passes them on to appenders using a separate thread. It might be that you decide the log4j async appender is not appropriate (here are some complaints about it), you could always make your own appender.