File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes location of log file when using log4j Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "location of log file when using log4j" Watch "location of log file when using log4j" New topic

location of log file when using log4j

zelynn goay
Ranch Hand

Joined: Jan 09, 2005
Posts: 30
hi. i am using log4j to log in my servlet. the servlet will read a .properties file that will be used by log4j.

i specify in the .properties file my log file location as
and i found the log file in <tomcat>/bin/

if i specify <code>log4j.appender.R.File=.\\logs\\example.log</log>, the log file will appear in <tomcat>/bin/logs

i wish to specify in my <tomcat>/webapps/myapp/log dir. may i know how should i do that?

Appreciate any help.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

If you use a relative link, the file location will be relative to the present working directory for that JVM (in your case the bin directory).
If you provide an absolute path, you can put it whereever you want.

I don't know how well it's supported but I've been able to use system properties to build the path:

In this case the logs are going to the TOMCAT/logs directory.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: location of log file when using log4j
It's not a secret anymore!