本文介绍了将参数传递给log4j文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我听说Java中的.properties文件可以接受字符串参数({0},{1},等等...)
I have heard that a .properties file in java can accept String arguments ({0}, {1}, and so on...)
能否请您提供一个示例来说明如何在log4j.properties文件中使用这些类型的参数?
Can you please provide an example to show how to use these kind of arguments in the log4j.properties file?
此外,请帮助提供示例代码,以显示如何在加载文件时将参数传递给文件.
Also, please help with a sample code showing how to pass the argument to the file while loading the file.
链接到任何有用的文章也有帮助
Links to any useful articles will also help
推荐答案
在log4j文件中:
log4j.appender.file.File=${log4jjava}
在您的Java代码中(初始化log4j的类):
In your java code(the class that init log4j):
System.setProperty("log4jjava", PATH_YOU_WANT_TO_SET);
//then load your property file
这篇关于将参数传递给log4j文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!