This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

location of log file when using log4j

 
zelynn goay
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
<code>
log4j.appender.R.File=example.log
</code>
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
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic