[logback-dev] [JIRA] Updated: (LBCORE-42) add option to FileAppender to auto-create parent directories

Joel (JIRA) noreply-jira at qos.ch
Wed Oct 8 20:05:39 CEST 2008

     [ http://jira.qos.ch/browse/LBCORE-42?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Joel updated LBCORE-42:

    Attachment: FileAppender.java.patch

Any missing parent directories have been automatically created for file appenders in log4j since version 1.2.12.  I believe this should be logback's default behavior as well, rather than making it an optional behavior.  This will make things more natural for users migrating from log4j.

I have attached a patch that will attempt to create missing parent directories.  The code is copied directly from log4j's FileAppender.setFile().  Feel free to include the patch directly in logback, or use it as the basis of a suggested solution.  Since the code was copied from log4j, I'm not sure if there are licensing issues that would prevent using the code directly as is.

> add option to FileAppender to auto-create parent directories
> ------------------------------------------------------------
>                 Key: LBCORE-42
>                 URL: http://jira.qos.ch/browse/LBCORE-42
>             Project: logback-core
>          Issue Type: Bug
>          Components: Appender
>    Affects Versions: unspecified
>         Environment: Operating System: Linux
> Platform: PC
>            Reporter: Bruno Navert
>            Assignee: Logback dev list
>         Attachments: FileAppender.java.patch
> FileAppender should be able to automatically create parent directories as needed when writing the log file.
> For instance, if configured with <File>/var/tmp/project_name/some_file.log</File>, and the new option set to true (suggest <CreateParentDirectories>true</CreateParentDirectories> maybe), then in FileAppender.setFile(), it should do
> new File( fileName ).getParentFile().mkdirs()
> workaround is to create the directory before initializing logback. Possible but far less than ideal, and rather complicated too

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the logback-dev mailing list