本文介绍了使用log4j2的多个线程的不同日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个Java应用程序,我在其中调用多个线程,每个线程都有一些唯一的名称。现在我想为每个日志文件创建多个日志文件,日志文件的名称应该作为线程名称。这可能是使用log4j2。请帮我写log4j2配置文件。

I am running a Java application in which I am invoking multiple threads, each with some unique names. Now I want to create multiple log files for each of them and the name of the log files should be as the thread names. Is this possible using log4j2. Please help me write log4j2 configuration files.

提前谢谢。

推荐答案

这可以使用RoutingAppender完成。 FAQ页面有一个很好的示例配置。

This can be done with the RoutingAppender. The FAQ page has a good example config.

这篇关于使用log4j2的多个线程的不同日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 04:28