A software’s log4j framework could not find the log4j configuration file which I specified. Details with debug below:
java -Dlog4j.debug=true -Dlog4j.configuration=/mysoftware/config/mylog4j.properties ...
log4j: Trying to find [mysoftware/config/mylog4j.properties] using context classloader sun.misc.Launcher$AppClassLoader@164b95.
log4j: Trying to find [mysoftware/config/mylog4j.properties] using sun.misc.Launcher$AppClassLoader@164b95 class loader.
log4j: Trying to find [mysoftware/config/mylog4j.properties] using ClassLoader.getSystemResource().
log4j: Could not find resource: [mysoftware/config/mylog4j.properties].
I did not want to use the default location for the log4j configuration file and wanted to be able to specify to a file with a name and location of my choice.
The debug output indicates that the absolute path of the resource (log4j.properties) is missing a beginning “/”. That’s because the file:// protocol was not specified. So, the following worked and enabled log4j locate the properties file:
java -Dlog4j.debug=true -Dlog4j.configuration=file:///mysoftware/config/mylog4j.properties ...
NOTE: If your log4j configuration file is called log4j.xml or log4j.properties, then placing it in the application classpath will suffice and you will not need the -Dlog4j.configuration option.
The file:// protocol was not used to specify the log4j configuration file.
(1) The solution above describes a successful problem-solving experience and may not be applicable to all problems with similar symptoms.
(2) Your rating of this post will be much appreciated. Also, feel free to leave comments.