tags:

views:

53

answers:

3

Hi, 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.

+1  A: 

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/

Laurent
A: 

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.

Yishai
A: 

I have tried what Yishai has suggested but no success.

Can you suggest, any other options?

naveen garimella