File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Relative path is not working for log4j after restarting apache in load balancing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Relative path is not working for log4j after restarting apache in load balancing" Watch "Relative path is not working for log4j after restarting apache in load balancing" New topic
Author

Relative path is not working for log4j after restarting apache in load balancing

nitin yeola
Greenhorn

Joined: Mar 27, 2012
Posts: 18
Hello,

we have given relative path in log4j configuration but when we restart apache in our load balancing
server our log generation stops.

please help if any one know about this.

Thanks.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

Does it stop, or do the logs perhaps end up somewhere you don't know about? If it really stops, perhaps Tomcat doesn't have the rights to write to the location.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
nitin yeola
Greenhorn

Joined: Mar 27, 2012
Posts: 18
Actually its generating before restart of apache but we have to restart tomcat to start generation of log again.

whether is it some relative path issue with log4j?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960
    
  19

It's better not to use relative paths for web-related resources. The concept of a fixed "working directory" that applies everywhere in the server and apps is not guaranteed. Any component can change its working directory at any time without warning. So absolute paths are much safer.


Customer surveys are for companies who didn't pay proper attention to begin with.
nitin yeola
Greenhorn

Joined: Mar 27, 2012
Posts: 18
Thanks.

Then I have to change path every time wherever I have to installed my application..
Because I have testsite, localsite, production so need to careful everytime while deploying application.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960
    
  19

nitin yeola wrote:Thanks.

Then I have to change path every time wherever I have to installed my application..
Because I have testsite, localsite, production so need to careful everytime while deploying application.


A WAR that has to be custom-built depending on where it's being deployed isn't "complete". If you do it right (admittedly, it's extra work), the same WAR can be used everywhere. That's my preferred approach, since it saves me from accidentally dropping the wrong WAR on the wrong server AND it ensures that when I test, the WAR is the same WAR that's running in production.

One of the best ways to ensure this portability is to use the Tomcat Context resource definition elements. You set them in each Tomcat server as part of the initial deployment, and in most cases, you leave them there unchanged thereafter. They contain the host-dependent settings such as what security Realm you're using, locations of external workfile directories, locations of log directories, and whatever else may vary from server to server. The values can be retrieved in the webapp using JNDI.
 
wood burning stoves
 
subject: Relative path is not working for log4j after restarting apache in load balancing
 
Similar Threads
session swapping - the burning issue
configure tomcat or apache to share a common session
Configuring Apache Tomcat F5 load balancing
Load balancing of tomcat server for my project
load balancing in Apache-Tomcat