The logging in my webapp works fine... until it is packaged in a WAR. When used from a WAR, this code:
...gives null. Is there any other way I can access it without having to specify and absolute locations anywhere (as my webapp needs to work from the WAR on any machine without pre-configuration).
So I hope it may work for you, String path = new File(".").getCanonicalPath();
James Hodgkiss wrote:Thanks for that, but my web app is deployed in an unexploded way.
Bearing that in mind, is there any way my servlet can create a subdirectory in the root directory then output the files there (without hardcoding any absolute paths into my web app)?
It's unlikely. The user id that is running the web container is not likely a root user (it shouldn't be) so it won't be able to create directories off the root. Consider using an existing directory such as /var/log/.
I'm still not sure why you need to create a directory for logging. Have you created your own logging framework? I've used log4j and java.util.Logging and both put the log files in /var/log/tomcat5.