log4j configuration via JVM argument(s)?

jconlin picture jconlin · Apr 22, 2009 · Viewed 189.5k times · Source

What variables do I have to set/pass as arguments to the JVM to get log4j to run properly? And by properly I mean not complain and print to the console. Can I see a typical example?

Note: I need to avoid creating a log4j.properties file in the application.

Answer

Brian Agnew picture Brian Agnew · Apr 22, 2009

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