tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <Yoav.Shap...@mpi.com>
Subject RE: installing with web app mgr, failing on getRealPath("")
Date Tue, 13 Aug 2002 13:06:00 GMT
Hi,

>What's the deal? I want to set a path to a log file by obtaining the
>app realpath and then subtracting "/webapps/" and substituting
>"/logs/". Is there a better way to do that?

For portability sake, so that you can deploy from a WAR file and don't
require it to be exploded, there are a couple of options.

- Include the complete path to a log file in your deployment descriptor,
as a context-param or init-param to some startup servlet.

- Log to a database, syslog, or another external facility.

- Log to the temporary directory (javax.servlet.context.tempdir) and
copy / persist the file upon shutdown.  Kind of similar to the first
option above, so I prefer the init-param approach.

getRealPath() will not work when deploying from a WAR, as you are doing
with the Manager app.  See the JavaDoc for ServletContext.getRealPath()
for details.  That will lead to another option:

- Use getResource() to construct the log file path with the same logic
as your original request.

I hope that helps a bit,

Yoav Shapira
Millennium ChemInformatics

--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message