java - 自定义 Log4j 文件名

标签 java log4j

我的log4j文件名为log4j2.xml 我需要自定义文件名,如 log4j2-A.xml、log4j2-B.xml 并读入应用程序。怎样才能做到呢?

最佳答案

Log4j2 documentation说这个...

How do I specify the configuration file location?

By default, Log4j looks for a configuration file named log4j2.xml (not log4j.xml) in the classpath.

You can also specify the full path of the configuration file with this system property: -Dlog4j.configurationFile=path/to/log4j2.xml

That property can also be included in a classpath resource file named log4j2.component.properties.

Web applications can specify the Log4j configuration file location with a servlet context parameter. See this section of the Using Log4j 2 in Web Applications manual page.

关于java - 自定义 Log4j 文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45942329/

相关文章:

java - MySQL自动增量设置为22378;新记录分配 id = 1

java - Git merge 两个分支与移动的文件

java - kill -退出: log not getting appended

java - 无法为 log4j 设置 LevelRangeFilter

java - 具有多层的 JFrame

java - 获取具有最大值的对象列表

java - 获取算法的运行时间

hadoop - Hadoop MapReduce java 类中的最佳日志记录方法是什么?

java - 使用标志批处理运行 java 应用程序

java - hsqldb 内部事件日志配置