• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
nitin yeola
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
nitin yeola
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
nitin yeola
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic