This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Using FileAppender - Unable to log to a file  RSS feed

 
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
 
Bartender
Posts: 19660
92
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!