• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

why is log4j not working in executable jar?

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've got a project that I jar into an executable jar with ant. I then zip up the executable jar along with the dependent jars it needs as well as a couple text files it reads. I've got the dependent jars listed in the class-path of the manifest file, the program can read the text files, all that appears to be working. It is structured in the zip file so that the executable jar, the dependent jars, and the text files are all in the same directory, like so:

/unzippedDir
myExecutable.jar
file1.txt
file2.txt
log4j.xml
commons-httpclient-3.1.jar
log4j-1.2.15.jar
other jars, etc.

Now I'm trying to enable logging because the user is having issues that I can't reproduce, so I'd like to be able to create logs that he can send me.

The logging works fine when run from Eclipse (it's a swing app). But there's no logging when run from the executable jar. I've put log4j.xml into the same directory as everything else listed above, and added log4j.xml to the class-path of the manifest file.

What am I missing?

Thanks
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post the contents of your Manifest file please
 
Bob Peterson
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm, that looks OK, I assume you're running java -jar to execute your app?
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh also, can you try removing the log4j.xml and make sure that the common-logging is using log4j (you should see a message print out that there's no log4j configuration file), something like:

log4j:WARN No appenders could be found for logger (com.example.App).
log4j:WARN Please initialize the log4j system properly.
 
Bob Peterson
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I'm just double-clicking on the executable jar in a windows explorer view.
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try running the jar file from the command prompt with the java -jar command and see what output it gives
[ August 27, 2008: Message edited by: Martijn Verburg ]
 
Sheriff
Posts: 28413
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The classpath is supposed to be a list of directories and jar files. You can't put individual files into the classpath. That's why your log4j.xml file isn't in the classpath, the way you have things set up. Try putting the directory "." into the classpath.
 
Bob Peterson
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wohoo, that did it! (putting directory "." in the classpath)

Thanks Paul! Thanks also to Martijn for his quick responses.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic