This week's book giveaway is in the Python forum.
We're giving away four copies of Python Continuous Integration and Delivery and have Moritz Lenz on-line!
See this thread for details.
Win a copy of Python Continuous Integration and Delivery this week in the Python forum!
  • 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

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
 
Saloon Keeper
Posts: 20508
115
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
 
Always! Wait. Never. Shut up. Look at this tiny ad.
Become a Java guru with IntelliJ IDEA
https://www.jetbrains.com/idea/
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!