The moose likes Other Open Source Projects and the fly likes log4j / eclipse / linux Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Reply Bookmark "log4j / eclipse / linux" Watch "log4j / eclipse / linux" New topic
Author

log4j / eclipse / linux

Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
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
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1340
Try adding debug param, it's probably not finding your properties file:

-Dlog4j.debug
Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
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
Ranch Hand

Joined: Oct 10, 2000
Posts: 1340
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

Joined: Feb 03, 2004
Posts: 456
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
Ranch Hand

Joined: Oct 10, 2000
Posts: 1340
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

Joined: Feb 03, 2004
Posts: 456
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
 
 
subject: log4j / eclipse / linux
 
Threads others viewed
Log4j stopped working
how to consume a webservice using axis2
log4j:WARN No appenders could be found for logger (net.Encryption.Scrambler).
Logging
Log4j in a web application
IntelliJ Java IDE