Advertisement
Guest User

log4j-extras call mkdirs() for rollover

a guest
Oct 24th, 2015
859
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.77 KB | None | 0 0
  1. Index: pom.xml
  2. ===================================================================
  3. --- pom.xml (revision 1710268)
  4. +++ pom.xml (working copy)
  5. @@ -25,7 +25,7 @@
  6.    <groupId>log4j</groupId>
  7.    <artifactId>apache-log4j-extras</artifactId>
  8.    <packaging>bundle</packaging>
  9. -  <version>1.2.17</version>
  10. +  <version>1.2.18-SNAPSHOT</version>
  11.    <name>Apache Extras™ for Apache log4j™.</name>
  12.    <description>
  13.        This package provides additional appenders, filters and
  14. Index: src/main/java/org/apache/log4j/rolling/helper/FileRenameAction.java
  15. ===================================================================
  16. --- src/main/java/org/apache/log4j/rolling/helper/FileRenameAction.java (revision 1710268)
  17. +++ src/main/java/org/apache/log4j/rolling/helper/FileRenameAction.java (working copy)
  18. @@ -17,7 +17,10 @@
  19.  
  20.  package org.apache.log4j.rolling.helper;
  21.  
  22. +import org.apache.log4j.helpers.LogLog;
  23. +
  24.  import java.io.File;
  25. +import java.io.IOException;
  26.  
  27.  
  28.  /**
  29. @@ -74,6 +77,17 @@
  30.    public static boolean execute(
  31.      final File source, final File destination, boolean renameEmptyFiles) {
  32.      if (renameEmptyFiles || (source.length() > 0)) {
  33. +      try {
  34. +        final File newFile = new File(destination.getCanonicalPath());
  35. +        final boolean dirCreated = newFile.getParentFile().mkdirs();
  36. +        if (dirCreated) {
  37. +          LogLog.debug("Successfully created directory path: " + newFile.getParentFile().toString());
  38. +        } else {
  39. +          LogLog.warn("Directory entries already existed or mkdirs() was denied to write directory path: " + newFile.getParentFile().toString());
  40. +        }
  41. +      } catch (IOException e) {
  42. +        LogLog.error("Failed to created directory, reason: " + e.getMessage());
  43. +      }
  44.        return source.renameTo(destination);
  45.      }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement