I'm not sure I agree that creating the directory that the use specifies is
doing something "behind the user's back" any more than log4j creating the
log file itself is. The user's saying "I want the file here," so creating
the file there (directory and filename) is doing exactly what the user asked
for. Permissions through that point must be writable, of course, or you'd
be violating security, but creating a file/directory in a writable
file/directory is fine from a security perspective.
-Jim Moore
-----Original Message-----
From: Ceki Gülcü [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 30, 2001 10:06 AM
To: LOG4J Developers Mailing List
Subject: Re: automatic creation of output directory
Elisabeth,
It is the user's responsibility to make sure that the destination file is
writable. log4j avoids doing things behind the user's back. If the directory
does not exists then logging fails for the relevant appender. Regards, Ceki
At 15:20 30.05.2001 +0200, you wrote:
>Hello,
>
>I have a problem concerning the creation of output files.
>Apparently, if the directory of the output file specified in the
>configuration file does not exist, log4j does not create it but throws
>an Exception.
>As it would be useful in our project to have these directories created
>automatically, I tried to change this. Here's my suggestion:
>
> public
> synchronized
> void setFile(String fileName, boolean append)
> throws IOException {
> reset();
> // modifications from here
> File fi = new File(fileName);
> if ( !(fi.getParentFile().exists() )){
> if (!(fi.getParentFile().mkdirs()))
> return; // ? not sure if we can return safely here
> }
> // until here
> this.setQWForFiles(new FileWriter(fileName, append));
> this.tp = new TracerPrintWriter(qw);
> this.fileName = fileName;
> this.qwIsOurs = true;
> }
>
>has anyone had the same problem, or an idea why it would be not
>recommended to do so?
>
>thanks
>Elisabeth
--
Ceki Gülcü
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]