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
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]

--
Ceki Gülcü


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to