• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

log4j / eclipse / linux

 
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi there,

i'm using log4j since years but this drives me crazy. but until now i was developing on windows with jetbrain's idea, this is my helloworld in eclipse on linux.

my logging.properties is extremely simple, actually it's from the log4j documentation.



i'm passing the location into the JVM as a classpath argument:



i'm dumping the system properties in my code, and i can see that the variable realy made it into the JVM

that's how i get my logger:


and that's how i log:


and that's what elipse's console says:


:-(

i have no clue, being stuck here since days...

any ideas?

many thanks & greetings,
jan
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try adding debug param, it's probably not finding your properties file:

-Dlog4j.debug
 
Jan Groth
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello carol,

thanks for your reply, this gave me new ideas. please look at the following code:



and here's the system output (with the debug parameter set)



okay.

debug says that log4j cannot open the resource. but if i read the configuration property manualy, i can build a file object without problems. i'm using the same path as the property is set to.

i'm in the same classloader.

hmm.

any ideas?

;-)

many thanks,
jan.
 
Carol Enderlin
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As indicated by the log4j debug it is looking for config/logging.properties on your classpath and it cannot find it. So, is the config directory on the classpath?

log4j short manual
 
Jan Groth
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hm, maybe i'm missing something here, but what does the config directory want in my classpath?

if

is able to read the config file, why should I add the directory to the classpath?

my interpretation is: the JVM is able to open the file, either addressed like above or through log4j business code... so this cannot be the cause.

i'm doing all my configuration through eclipse, adding my project home & junit.jar & log4j.jar to my project environment. a class path is not set.

i'd say that's not the root of my problem, or am i wrong in my argumentation?

many greetings,
jan
 
Carol Enderlin
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do not see in your code that your File manipulation is actually finding the file. Did you read from the file or do a file.exists() or perhaps see what you get back with getAbsolutePath() or getCanonicalPath()?

Look at the log4j debug output...the classloaders are looking for config/logging.properties and cannot find it.
 
Jan Groth
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
two issues:

first (and most important): the problem is solved, this article helped me a lot. it was a classpath problem. i was unaware that eclipse seems to interfere the vm-args and needs its own configuraton variable. i don't know if this is for any good reasons, i found intellij-idea far more intuitive for the user

second: concerning your last answer, carol: well, my testcode actually was able to _read_ the whole file, line by line. but my assumption "if _i_ can the file, log4j can too" was wrong. i debugged into the logger, and found that log4j uses (better: tries) different classloaders and their getRessource() methods to load the file. And those fall back on the set class path, no matter if "/config" is reachable from with a eclipse java-program or not. i find this pretty strange... ;-)

many thanks for your help & greetings from berlin / germany,
jan
reply
    Bookmark Topic Watch Topic
  • New Topic