File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes log4j config file giving FileNotFoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "log4j config file giving FileNotFoundException" Watch "log4j config file giving FileNotFoundException" New topic
Author

log4j config file giving FileNotFoundException

kwame Iwegbue
Ranch Hand

Joined: Sep 02, 2000
Posts: 197
Hi,
I'm new to log4j and trying to configure it from an init method in a servlet, by passing a properties file to PropertyConfigurator.



The web.xml has the file as:



on startng up the server, i'm getting this error:



The properties file is properly written and saved in the location stated in the error message.
Is someone familiar with this problem? please help.


Who dares, wins! (SAS motto)
Srinivas Kalvala
Ranch Hand

Joined: Oct 20, 2005
Posts: 257

Hello,

1) Make sure that the file really exists.

2) If it exists then, make sure that you got read permission to read the file, as the PropertyConfigurator() will make the FileInputStream to the corresponding file directly.

3) If you have right access then , write a simple jsp page, to find path of the file.

4) Even it does not work, then use ClassLoader directly to load the .property file and call Propertyconfigurator() to read the stystem resource.

double check whether you got .properties file in your classes folder.
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
I think this should work if the right file is there in the mentioned location.


Rahul Bhattacharjee
LinkedIn - Blog
kwame Iwegbue
Ranch Hand

Joined: Sep 02, 2000
Posts: 197
I was having way too much trouble with PropertyConfigurator, so I decided to place log4j.properties file in WEB-INF/classes and let Log4j find it and initialize it itself. I'm using Tomcat 5.5 with Eclipse 3.2.

This is the log4j.properties file:



and this is part of the Tomcat log:



What does this mean??? I thought Log4j was supposed to be easy to use
kwame Iwegbue
Ranch Hand

Joined: Sep 02, 2000
Posts: 197
my app seems to print log statements inspite of those error messages. but i would still love to know what this refer to:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: log4j config file giving FileNotFoundException