package ch.qos.logback.core.rolling; import ch.qos.logback.core.rolling.RollingFileAppender; import ch.qos.logback.core.FlushableAppender; import java.io.File; import java.io.IOException; /** * Customized {@link RollingFileAppender} implementation that automatically creates parent directories in the log file * path. *

* This has been filed as a Bugzilla Bug for Logback: http://bugzilla.qos.ch/show_bug.cgi?id=137 *

* Delete this class once the bug has been fixed and the new version is available internally. * * @author brunon * @version $$Revision: #1 $$, $$DateTime: 2008/08/08 16:03:34 $$ * @since Mar 20, 2008 */ public class DirectoryCreateRollingFileAppender extends RollingFileAppender implements FlushableAppender { @Override public synchronized void setFile() throws IOException { // create parent directories as needed new File( fileName ).getParentFile().mkdirs(); // then proceed as usual super.setFile(); } public void flush() throws IOException { writer.flush(); } }