You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Brian McGovern <bm...@imediainc.com> on 2005/02/21 23:02:14 UTC

log4j.properties not found in tomcat

I have a wierd problem.  Tomcat on W2k barks FileNotFound Exceptions for the log4j.properties file when i execute a servlet that instantiates log4j.  Strangely enough the actual file that i create and log to with log4j.properties file logs out just fine even though stdout.log said that it couldn't find my log4j.properties file.  

Only time i don't get an error is when i put log4j.properites in my winnt/system32 directory.  But this doesnt make sense to me.  I supply -Dlog4j.configuration=log4j.properties to Java at startup and still get the same error.  I also tried the FULL path to my log4j.properties in the -D option.  

Instantiated like this across my app.

private static final Logger zLogger = Logger.getLogger(MyClassName.class); 

Can anyone tell me where I went wrong.  

thanks

Re: log4j.properties not found in tomcat

Posted by Jacob Kjome <ho...@visi.com>.
You have to understand that any relative path is going to be resolved 
relative to the location where the JVM started.  If you started Tomcat via 
the service rather than the batch files, then the VM would be run, by 
default, from C:\winnt\System32.  So, when you supplied 
"-Dlog4j.configuration=log4j.properties", you got exactly what should be 
expected if log4j.properties were located in c:\winnt\System32.  Same goes 
for relatively defined paths to log files defined for FileAppenders in 
log4j.properties.

BTW, can you post your error?   FileNotFoundExceptions aren't thrown when 
Log4j can't find its config file.  You'd get a simple error saying as 
much.  The FileNotFoundExceptions are usually thrown when you specify a 
file for a FileAppender in a directory that doesn't exist.  Log4j makes no 
attempt to create directories if they don't exist already.  This is the 
correct and safe thing to do.  It is your responsibility to make sure the 
directory exists before Log4j attempts to use it.


Jake

At 11:09 PM 2/21/2005 -0500, you wrote:
 >Where do you put  log4j.properties currently?
 >-Michael Greer
 >
 >On Feb 21, 2005, at 5:02 PM, Brian McGovern wrote:
 >
 >> I have a wierd problem.  Tomcat on W2k barks FileNotFound Exceptions
 >> for the log4j.properties file when i execute a servlet that
 >> instantiates log4j.  Strangely enough the actual file that i create
 >> and log to with log4j.properties file logs out just fine even though
 >> stdout.log said that it couldn't find my log4j.properties file.
 >>
 >> Only time i don't get an error is when i put log4j.properites in my
 >> winnt/system32 directory.  But this doesnt make sense to me.  I supply
 >> -Dlog4j.configuration=log4j.properties to Java at startup and still
 >> get the same error.  I also tried the FULL path to my log4j.properties
 >> in the -D option.
 >>
 >> Instantiated like this across my app.
 >>
 >> private static final Logger zLogger =
 >> Logger.getLogger(MyClassName.class);
 >>
 >> Can anyone tell me where I went wrong.
 >>
 >> thanks
 >
 >
 >---------------------------------------------------------------------
 >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
 >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
 >
 >  


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: log4j.properties not found in tomcat

Posted by Michael Greer <mi...@earthlink.net>.
Where do you put  log4j.properties currently?
-Michael Greer

On Feb 21, 2005, at 5:02 PM, Brian McGovern wrote:

> I have a wierd problem.  Tomcat on W2k barks FileNotFound Exceptions 
> for the log4j.properties file when i execute a servlet that 
> instantiates log4j.  Strangely enough the actual file that i create 
> and log to with log4j.properties file logs out just fine even though 
> stdout.log said that it couldn't find my log4j.properties file.
>
> Only time i don't get an error is when i put log4j.properites in my 
> winnt/system32 directory.  But this doesnt make sense to me.  I supply 
> -Dlog4j.configuration=log4j.properties to Java at startup and still 
> get the same error.  I also tried the FULL path to my log4j.properties 
> in the -D option.
>
> Instantiated like this across my app.
>
> private static final Logger zLogger = 
> Logger.getLogger(MyClassName.class);
>
> Can anyone tell me where I went wrong.
>
> thanks


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org