You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by dp...@apache.org on 2017/06/22 20:47:53 UTC

[05/10] logging-log4net git commit: Try and trap a date when looking for the next backup number.

Try and trap a date when looking for the next backup number.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4net/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4net/commit/ea259c6b
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4net/tree/ea259c6b
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4net/diff/ea259c6b

Branch: refs/heads/pr/old/29
Commit: ea259c6bf0f8676af232a970b7c774ca233fd0cb
Parents: 563311c
Author: Steven Nicholas <st...@snware.com>
Authored: Thu Jun 22 22:31:14 2017 +0200
Committer: Dominik Psenner <dp...@apache.org>
Committed: Thu Jun 22 22:31:14 2017 +0200

----------------------------------------------------------------------
 src/Appender/RollingFileAppender.cs | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/ea259c6b/src/Appender/RollingFileAppender.cs
----------------------------------------------------------------------
diff --git a/src/Appender/RollingFileAppender.cs b/src/Appender/RollingFileAppender.cs
index 816549c..f0d5ab4 100644
--- a/src/Appender/RollingFileAppender.cs
+++ b/src/Appender/RollingFileAppender.cs
@@ -1010,13 +1010,20 @@ namespace log4net.Appender
             {
                 fileName = Path.GetFileNameWithoutExtension(fileName);
             }
-            
+
             int index = fileName.LastIndexOf(".");
             if (index > 0)
             {
                 // if the "yyyy-MM-dd" component of file.log.yyyy-MM-dd is passed to TryParse
-                // it will gracefully fail and return backUpIndex will be 0
+                // it will gracefully fail and return backUpIndex will be 0.
+                // If the date format does not contina any -'s then we have to do additional checks.
                 SystemInfo.TryParse(fileName.Substring(index + 1), out backUpIndex);
+
+                // We may have picked up a date in a format without "-" eg. yyyyMMdd...
+                if (backUpIndex > m_maxSizeRollBackups && m_rollDate)
+                {
+                    backUpIndex = 0;
+                }
             }
 
             return backUpIndex;