aspose file tools*
The moose likes JSF and the fly likes Where should I keep my application's log files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Where should I keep my application Watch "Where should I keep my application New topic
Author

Where should I keep my application's log files

B Nirvan
Ranch Hand

Joined: Oct 20, 2010
Posts: 82
I will be hosting a web application for a NPO on a third party hosting provider. I have to log some exceptions and some informational messages for asynchronous processing. Since the logging requirements are quite simple, I decided to go ahead with the java logging api. Now I am unsure as to where the log files should reside. I can't put them in my application's jar, since they will be erased when I redeploy my application for some reason (and some other reasons also). I don't think the hosting provider will provide access to any other real file path on his server. Can anyone provide me with some insight as to where the log files should normally be placed.

regards,
Nirvan.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18985
    
    8

As you correctly observe, putting log files inside directories which belong to your web application is a bad idea. So as you have already figured out, you should store them somewhere else.

There really isn't much more to be said. "Somewhere else" gives you plenty of places to choose from. However if there are restrictions on your choice which are imposed by a third party... you can't really expect us to make suggestions, because we know nothing about those restrictions. If it were me I would just ask that third party for the suggestions.
B Nirvan
Ranch Hand

Joined: Oct 20, 2010
Posts: 82
Paul,
Perhaps I should I consulted the hosting provider before posting the question. Anyway, now that I am sure that log files shouldn't be placed in application jar, I have a fair idea what to negotiate. Thanks for the advice,

regards,
Nirvan.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

Actually, you shouldn't write anything into the webapp itself. For a strict J2EE implementation, that would require cracking open the WAR file and updating it. Even when dealing with "exploded" WARs, there are problems, as you have so astutely observed.

Windows has no standard place to put logs. You're on your own there.

In Linux, there are coventional locations:

/var/log is used to hold log files (and directories) for system applications

/var/lib/appname is common usage for applications with a lot of infrastructure.

/opt is also common for third-party apps. I've been known to use things like "/opt/com/mousetech/appname", for example.

/usr/local/appname is a legacy base. My Tomcat logs, for example, are in /usr/local/tomcat6/logs/catalina.out, etc. This is not recommended, however, since properly speaking, /usr/local should be read-only these days. Some configurations put the /usr/local/tomcat6/logs as a softlink to someplace like /var/lib/tomcat6/logs

/srv is a relatively new location for server stuff.

On the whole, /var is the best root for logfiles, since it's the conventional place to put things that grow. Where exactly under /var you put things is subject to debate. My own practice would generally be /var/lib/mywebapp/logs, but YMMV.

It is in the best interest of your hosting provider to agree on somewhere, however!


Customer surveys are for companies who didn't pay proper attention to begin with.
B Nirvan
Ranch Hand

Joined: Oct 20, 2010
Posts: 82
Tim,
Thanks for the explanation. The hosting provider will be hosting glassfish server on windows, so I guess we will have to mutually decide on the best place for the logs.

regards,
Nirvan.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Where should I keep my application's log files