[Bug 137] New: add option to FileAppender to auto-create parent directories

http://bugzilla.qos.ch/show_bug.cgi?id=137 Summary: add option to FileAppender to auto-create parent directories Product: logback-core Version: unspecified Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P1 Component: Appender AssignedTo: logback-dev@qos.ch ReportedBy: bruno.navert@morganstanley.com 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 -- Configure bugmail: http://bugzilla.qos.ch/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee.

http://bugzilla.qos.ch/show_bug.cgi?id=137 ------- Comment #1 from bruno.navert@morganstanley.com 2008-03-20 16:44 ------- This subclass does the trick, but an option in FileAppender would be much better (I used RollingFileAppender because this is what I needed in my project): public class DirectoryCreateRollingFileAppender<E> extends RollingFileAppender<E> { @Override public synchronized void setFile() throws IOException { // create parent directories as needed new File( fileName ).getParentFile().mkdirs(); // then proceed as usual super.setFile(); } } -- Configure bugmail: http://bugzilla.qos.ch/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee.

http://bugzilla.qos.ch/show_bug.cgi?id=137 anders@hammar.net changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |anders@hammar.net ------- Comment #2 from anders@hammar.net 2008-04-03 08:51 ------- Creating the parent directories is the standard behavior of log4j (I checked v1.2.13), so I think this feature should be added to the FileAppender class (no sub-class). -- Configure bugmail: http://bugzilla.qos.ch/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee.
participants (1)
-
bugzilla-daemon@pixie.qos.ch