log4j configuration via JVM argument(s)?
Solution 1:
Do you have a log4j configuration file ? Just reference it using
-Dlog4j.configuration={path to file}
where {path to file} should be prefixed with file:
Edit: If you are working with log4j2, you need to use
-Dlog4j.configurationFile={path to file}
Taken from answer https://stackoverflow.com/a/34001970/552525
Solution 2:
The solution is using of the following JVM argument:
-Dlog4j.configuration={path to file}
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:\Users\me\log4j.xml
More information and examples here: http://logging.apache.org/log4j/1.2/manual.html
Solution 3:
This seems to have changed (probably with log4j2) to:
-Dlog4j.configurationFile=file:C:\Users\me\log4j.xml
See: https://logging.apache.org/log4j/2.x/manual/configuration.html
Solution 4:
I know this is already answered, but because you said, this isn't exactly what you are looking for, I would like to point out the following alternative:
You can also use a configuration class instead of the properties or xml file.
-Dlog4j.configuratorClass=com.foo.BarConfigurator
See http://logging.apache.org/log4j/1.2/manual.html for details.