并发 log4j

发布于 2024-11-09 12:17:35 字数 127 浏览 0 评论 0原文

我有自己的日志引擎,它将日志写入具有阻塞队列的单独线程上。为了使用“标准软件”,我正在考虑切换到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

傲娇萝莉攻 2024-11-16 12:17:35

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.

心舞飞扬 2024-11-16 12:17:35

查看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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文