如何异步使用log4j'的FileAppenders?[英] How to use log4j's FileAppenders asynchronously?

本文是小编为大家收集整理的关于如何异步使用log4j'的FileAppenders?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我从事低延期交易应用程序.我们想增加写入文件的LOF4J记录的数量,同时最大程度地减少对端到端处理时间的影响.

推荐的方法是什么?我认为fileappender.append是同步的,所以我们需要做一些比这更聪明的事情.

推荐答案

是的,附录是同步的.您想要这样的东西:

http://www.spartanjava comle -log4j/

其他推荐答案

请记住,AsyncAppender添加每个附录器的线程,并且增加您所做的记录量可能意味着要进行的字符串串联量的数量大幅增加,这通常意味着大量的字符串处理/弹奏/格式可能非常昂贵(相对于低潜伏期交易应用程序所涉及的延迟).

其他推荐答案

如果您需要从多线程应用程序登录 slf4j 及其实现 logback 是更好的选择.

本文地址:https://www.itbaoku.cn/post/1574865.html

问题描述

I work on a low-latency trading application. We'd like to increase the amount of lof4j logging that we write to file, whilst minimising the impact on our end-to-end processing time.

What is the recommended way of doing this? I think FileAppender.append is synchronous, so we need to do something a bit smarter than that....

推荐答案

Yes, the appenders are synchronous. You want something like this:

http://www.spartanjava.com/2009/asynchronous-logging-with-log4j/

其他推荐答案

bear in mind that AsyncAppender adds a thread per appender & that increasing the amount of logging you do may mean a substantial increase in the amount of string concatentation going on which often means a substantial amount of string processing/munging/formatting which can be pretty expensive (relative to the latency involved in a low latency trading app anyway).

其他推荐答案

If you need to log from a multithreaded application slf4j and its implementation logback are much better choice.

相关标签/搜索