gpt4 book ai didi

java - 自定义 Log4j 文件名

转载 作者:行者123 更新时间:2023-12-02 02:38:08 26 4
gpt4 key购买 nike

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

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com