This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using FileAppender - Unable to log to a file

 
Jim Patrick
Ranch Hand
Posts: 42
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18094
48
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jim Patrick
Ranch Hand
Posts: 42
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic