The solution is using of the following JVM argument:
-Dlog4j.configuration={path tofile}
If the file is NOT in the classpath (in WEB-INF/classes in case of Tomcat) but somewhere on you disk, use file:, like、
-Dlog4j.configuration=file:C:Usersmelog4j.xml
More information and examples here: http://logging.apache.org/log4j/1.2/manual.html
转载请注明:爱开源 » log4j 通过文件传入配置