开发者

How to force log4j load xml config from non src folder?

Is it possible to have log4j.xml loaded from a different dir than source root and开发者_JAVA技巧 how? (programmatically?) Meaning that it's somewhere in FS not just in classpath.


Using DOMConfigurator you can specify the the XML file used to configure log4j.

DOMConfigurator.configure("/path/to/log4j.xml");

For log4j.properties you can do the same thing with PropertyConfigurator.

PropertyConfigurator.configure("/path/to/log4j.properties");


This might not be the best way, but you can specify the location of the file by setting the java property log4j.configuration=path/to/config/file. For example, you can specify this directly to the java command with java -Dlog4j.configuration=path.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜