aspose file tools*
The moose likes Tomcat and the fly likes Using FileAppender - Unable to log to a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Using FileAppender - Unable to log to a file" Watch "Using FileAppender - Unable to log to a file" New topic
Author

Using FileAppender - Unable to log to a file

Jim Patrick
Ranch Hand

Joined: Dec 27, 2005
Posts: 42

Hi

In my sample java web application, I have configured log4j.

I have this in my log4j.properties:



In the RollingFileAppender section above, I have below line.
log4j.appender.myDebug.File=/logs/VPRJ_DEBUG.log

I can see the log in eclipse console window but there is no VPRJ_DEBUG.log file created anywhere.
could someone tell me where exactly the VPRJ_DEBUG.log file willl be created?
will it be created under C:\apache-tomcat-6.0.18\logs or somewhere in the WebContent folder in my application(I am using eclipse IDE)?

This is the exception in console:

INFO: Starting Servlet Engine: Apache Tomcat/6.0.18
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: \logs\VPRJ_DEBUG.log (The system cannot find the path specified)


Regards,
Jim
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16065
    
  21

On a Unix/Linux system, the logfile would be created in the /logs directory, providing one existed and Tomcat had proper access rights.

However, you're using Windows and I'm not sure. If Tomcat is on your C drive, you would probably be writing to C:\logs, and once again, it would have to exist and be updateable by Tomcat.

It's not a good idea to omit the drive ID, however, so this form would be better:


Note that I used the Java file path syntax, rather than the Windows backslash syntax, In Java, it's usually safer.


Customer surveys are for companies who didn't pay proper attention to begin with.
Jim Patrick
Ranch Hand

Joined: Dec 27, 2005
Posts: 42

Hi Tim,

First of all, thank you for the reply.
Probably the folks new to log4j FileAppenders find your reply very useful..

and all I did was, added "logs" folder in c: drive as suggested and it worked.


Regards,
Jim
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using FileAppender - Unable to log to a file