log file not generated while accessing a jar having log4j support
I have a x.jar which is being used by some client y.jar. Both x.jar and y.jar and log4j.xml are at the same package level.
But the log file is never generated. Can i know why?
I have tried few other options as well but no luck till now.
1) i have added log4j-1.2.16.jar to ClassPath: variable in manifest files of both x.jar and y.jar.
2) Put log4j.xml at the class level of y.jar which actually calls the x.jar classes.
package structure is as follows:
x.jar
--manifest.mf has a entry ClassPath:log4j-1.2.16.jar
y.jar --manifest.mf has a entry ClassPath:log4j-1.2.16.jar
log4j-1.2.16.jar
log4j.xml --has a RollingFileAppender开发者_如何学运维.
Can any one suggest whether i am missing anything?
Thanks,
Naveen Garimella.
You need to declare the path to the log4j configuration file by using the java property -Dlog4j.configuration=pathToYourLog4jConfigFile when you run your JAR:
java -jar -Dlog4j.configuration=file:log4j.xml my.package.MyClass
You can also try to avoid it by using what is explained here :
http://blog.blip.tv/blog/2005/07/24/log4jxml-inside-your-jar/
You can also add a single .
(to indicate the current directory for inclusion in the classpath) in the manifests, so that log4j can pick up the file.
精彩评论