You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by John McNally <jm...@collab.net> on 2002/02/04 19:19:43 UTC
Re: cvs commit: jakarta-turbine-3/src/java/org/apache/turbine
Turbine.java
What if the log directory is outside the webapp root? If I am writing
my logs to /home/jmcnally/logs, will this not create
<webapp_root>/home/jmcnally/logs? What happens if I do not have write
access to <webapp_root>?
john mcnally
dlr@apache.org wrote:
>
> dlr 02/02/04 09:19:26
>
> Modified: src/java/org/apache/turbine Turbine.java
> Log:
> Used new constant LOGGING_ROOT (from TurbineConstants interface) to
> allow override of the default logging directory of "/logs" (relative
> to web app root) to the value specified in the Turbine servlet's
> initialization parameters.
>
> Revision Changes Path
> 1.25 +13 -6 jakarta-turbine-3/src/java/org/apache/turbine/Turbine.java
>
> Index: Turbine.java
> ===================================================================
> RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/Turbine.java,v
> retrieving revision 1.24
> retrieving revision 1.25
> diff -u -u -r1.24 -r1.25
> --- Turbine.java 24 Jan 2002 03:55:26 -0000 1.24
> +++ Turbine.java 4 Feb 2002 17:19:26 -0000 1.25
> @@ -121,7 +121,7 @@
> * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
> * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
> * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
> - * @version $Id: Turbine.java,v 1.24 2002/01/24 03:55:26 jvanzyl Exp $
> + * @version $Id: Turbine.java,v 1.25 2002/02/04 17:19:26 dlr Exp $
> */
> public class Turbine
> extends HttpServlet
> @@ -567,7 +567,7 @@
> // runtime. Right now this creates the directories
> // for logging but we might have more of these
> // directories in the future.
> - createRuntimeDirectories();
> + createRuntimeDirectories(config.getInitParameter(LOGGING_ROOT));
>
> // Get the full path to the properties file.
> if (propsFile == null)
> @@ -704,14 +704,21 @@
> *
> * i) directories for logging
> *
> + * @param path The directory to write log files to (relative to
> + * the web application root), or <code>null</code> for the default
> + * of <code>/logs</code>.
> */
> - private static void createRuntimeDirectories()
> + private static void createRuntimeDirectories(String path)
> {
> - // Create the logging directory
> - File logDir = new File(getRealPath("/logs"));
> -
> + if (StringUtils.isEmpty(path))
> + {
> + path = "/logs";
> + }
> +
> + File logDir = new File(getRealPath(path));
> if (!logDir.exists())
> {
> + // Create the logging directory
> if (!logDir.mkdirs())
> {
> System.err.println("Cannot create directory for logs!");
>
>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: cvs commit: jakarta-turbine-3/src/java/org/apache/turbine Turbine.java
Posted by Daniel Rall <dl...@finemaltcoding.com>.
FWIW, it was already doing that. Even so, I think that John has a
good point here.
John McNally <jm...@collab.net> writes:
> What if the log directory is outside the webapp root? If I am writing
> my logs to /home/jmcnally/logs, will this not create
> <webapp_root>/home/jmcnally/logs? What happens if I do not have write
> access to <webapp_root>?
>
> john mcnally
>
> dlr@apache.org wrote:
> >
>> dlr 02/02/04 09:19:26
>>
>> Modified: src/java/org/apache/turbine Turbine.java
>> Log:
>> Used new constant LOGGING_ROOT (from TurbineConstants interface) to
>> allow override of the default logging directory of "/logs" (relative
>> to web app root) to the value specified in the Turbine servlet's
>> initialization parameters.
>>
>> Revision Changes Path
>> 1.25 +13 -6 jakarta-turbine-3/src/java/org/apache/turbine/Turbine.java
>>
>> Index: Turbine.java
>> ===================================================================
>> RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/Turbine.java,v
>> retrieving revision 1.24
>> retrieving revision 1.25
>> diff -u -u -r1.24 -r1.25
>> --- Turbine.java 24 Jan 2002 03:55:26 -0000 1.24
>> +++ Turbine.java 4 Feb 2002 17:19:26 -0000 1.25
>> @@ -121,7 +121,7 @@
>> * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
>> * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
>> * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
>> - * @version $Id: Turbine.java,v 1.24 2002/01/24 03:55:26 jvanzyl Exp $
>> + * @version $Id: Turbine.java,v 1.25 2002/02/04 17:19:26 dlr Exp $
>> */
>> public class Turbine
>> extends HttpServlet
>> @@ -567,7 +567,7 @@
>> // runtime. Right now this creates the directories
>> // for logging but we might have more of these
>> // directories in the future.
>> - createRuntimeDirectories();
>> + createRuntimeDirectories(config.getInitParameter(LOGGING_ROOT));
>>
>> // Get the full path to the properties file.
>> if (propsFile == null)
>> @@ -704,14 +704,21 @@
>> *
>> * i) directories for logging
>> *
>> + * @param path The directory to write log files to (relative to
>> + * the web application root), or <code>null</code> for the default
>> + * of <code>/logs</code>.
>> */
>> - private static void createRuntimeDirectories()
>> + private static void createRuntimeDirectories(String path)
>> {
>> - // Create the logging directory
>> - File logDir = new File(getRealPath("/logs"));
>> -
>> + if (StringUtils.isEmpty(path))
>> + {
>> + path = "/logs";
>> + }
>> +
>> + File logDir = new File(getRealPath(path));
>> if (!logDir.exists())
>> {
>> + // Create the logging directory
>> if (!logDir.mkdirs())
>> {
>> System.err.println("Cannot create directory for logs!");
>>
>>
>>
>>
>> --
>> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
>> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: cvs commit: jakarta-turbine-3/src/java/org/apache/turbine
Turbine.java
Posted by Jason van Zyl <jv...@zenplex.com>.
On 2/4/02 1:19 PM, "John McNally" <jm...@collab.net> wrote:
> What if the log directory is outside the webapp root? If I am writing
> my logs to /home/jmcnally/logs, will this not create
> <webapp_root>/home/jmcnally/logs? What happens if I do not have write
> access to <webapp_root>?
>
> john mcnally
I made the assumption that the logs would go to ${applicationRoot}, and if
that fails we can put the logs in ${webappRoot}. If you specify file paths
for the appenders and you don't use the ${applicationRoot} and you don't
have write access then are there some standard places (like /tmp) that we
can use to place log files where we can log a warning about not having write
access to the specified log directory? I agree that the logging should be
made failsafe.
--
jvz.
Jason van Zyl
http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>