问题描述
我对log4j网站上的解释有点困惑,请允许有人阐明我的无知.
该图表示的是应用程序当前用于运行其业务逻辑的应用程序线程数,还是代表所有异步记录器将由记录器或中断器使用的线程数.
换句话说,该图代表代表生成日志的线程还是代表代表log4j2消耗日志的线程.
I am little confused with the explanation on log4j site, could somebody please put some light on my ignorance.
Does the graph represents, the number of application threads currently used by application to run its business logic or it represents the number of threads that will be used by logger or disruptor in case of all Async Loggers.
In other words, does the graph represents the threads that are generating logs or does it represent the threads consuming logs on behalf of log4j2.
请分享一些官方参考,并且有任何方法可以配置记录器将使用的线程数.我不希望我的应用程序通过记录器线程进行记录,因此有什么方法可以配置log4j以减少CPU使用量.
Please share some official references and is there any way to configure the number of threads that will be used by logger.I don't want my application to slog by loggers thread so is there any way to configure log4j to use CPU less.
推荐答案
图中的线程数表示同时进行日志记录的应用程序线程数.
The number of threads in the graph represents the number of application threads that do logging concurrently.
使用异步记录器,只有一个后台线程可写入日志文件.
With Async Loggers there is only one background thread that writes to the log files.
该图显示的是,即使在高竞争情况下,用于将日志事件从多个生产者(应用程序)线程切换到单个消费者线程的数据结构也非常有效,从而导致更好的日志记录吞吐量.
What the graph shows is that the data structure used to handoff log events from the many producer (application) threads to the single consumer thread is very efficient even under high contention, resulting in much better logging throughput.
这篇关于使用异步记录器时,Log4j2产生多少个线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!