Archive

Archive for October, 2015

Overriding log4j property file

October 2, 2015 Leave a comment

Overriding log4j property file

Sometimes it is handy to override log4j behaviour. By default it looks for log4j.xml under classpath. But I had a need to override the xml with properties file that is coming from classpath. Just add following as a VM arguments to the program or server runtime arguments.

If log file is under classpath

  -Dlog4j.configuration=log4j.properties 

OR

 -Dlog4j.configuration=mylog4j.properties

If log file is outside classpath
Complete URL notation should be used as in:

 -Dlog4j.configuration=file:/c:/work/mylog4j.properties

OR

 -Dlog4j.configuration=file:/home/apps/work/mylog4j.properties