我的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/