Is there a reason you're not using a perfectly good, highly configurable, and very performant logging package (like
log4j )
As for what you're asking, there is no built-in way to get this. You'll have to parse the String yourself. One gotcha:
Tomcat can be configured to serve a web application from *anywhere*, not necessarily just from the CATALINA_HOME directories. So if you expect something of the form:
c:\tomcat\webapps\foo what happens when the application is actually deployed to:
c:\foo ?
c:\webapps\foo?
A second gotcha is that Tomcat can be configured to run from a packed WAR file, in which case getRealPath() will return null.
One option is to specify (as part of your application's setup specs or 'administrators guide') a variable in JNDI provides an absolute path to find the log file directory. So it would be a configuration option in web.xml, and your code would then retrieve the path to use from this file.
But if we're going that far, I'd start to really look hard at log4j.
If your concern is someone being able to retrieve your logs by entering (guessing) the filename and typing it directly into a browser window, you can place your logs in WEB-INF/logs (that's what I do, with log4j).
[ May 25, 2004: Message edited by: Mike Curwen ]