• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

log4j.properties not found

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to get my Java app to use log4j. I've stored my log4j.properties
file in the same directory as my TestLogging.class file but Log4j does not find the properties file there. What did I do wrong?
When I run my program I get these messages:
log4j: Trying to find [log4j.xml] using context classloader sun.misc.Launcher$AppClassLoader@12f6684.
log4j: Trying to find [log4j.xml] using sun.misc.Launcher$AppClassLoader@12f6684 class loader.
log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader sun.misc.Launcher$AppClassLoader@12f6684.
log4j: Trying to find [log4j.properties] using sun.misc.Launcher$AppClassLoader@12f6684 class loader.
log4j: Trying to find [log4j.properties] using ClassLoader.getSystemResource().
log4j: Could not find resource: [null].
log4j:WARN No appenders could be found for logger (logging.TestLogging).
log4j:WARN Please initialize the log4j system properly.
thanks for any clues,
Rich Smyth.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a servlet?
If so you need a class to configure log4j for the context

http://logging.apache.org/log4j/docs/manual.html
That above assumes you have a servlet level variable defined in your web.xml called log4j-init-file and it points to your .properties (or xml) file relative to the server's path. Initing via standalong is quite similar.
There are a ton of examples on that page above that should get you going. Pick the one that is closest to your implementation and let us know where you are having problems.
-c
[ March 29, 2004: Message edited by: Chad Dalton ]
 
Rich Smyth
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The tutorial I'm following has the instruction: "Save the following lines in a file named log4j.properties in the same directory as TestLogging.class "
I blindy did as instructed. My mistake. I should have noticed that this only works if TestLogging is in the default package. I stored the class in logging.TestLogging so the properties file was not at the root directory.
Thanks for the link Chad. I'm currently learning from http://www.vipan.com/htdocs/log4jhelp.html, which I find very well done.
Rich
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic