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.
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.
Joined: Oct 20, 2010
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,
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.
Joined: Oct 20, 2010
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.