You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by bo...@apache.org on 2017/05/01 17:33:56 UTC

[1/3] logging-log4net git commit: try to reproduce PR 23 of https://github.com/apache/log4net/pull/23

Repository: logging-log4net
Updated Branches:
  refs/heads/master 2229b4453 -> e9a9bb6bb


try to reproduce PR 23 of https://github.com/apache/log4net/pull/23


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

Branch: refs/heads/master
Commit: ce481db1bf3b556c7ebe7851546c9425d0b5c192
Parents: d0f3327
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun Apr 30 19:03:53 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun Apr 30 19:03:53 2017 +0200

----------------------------------------------------------------------
 src/Appender/RollingFileAppender.cs | 13 +++++++++++++
 1 file changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/ce481db1/src/Appender/RollingFileAppender.cs
----------------------------------------------------------------------
diff --git a/src/Appender/RollingFileAppender.cs b/src/Appender/RollingFileAppender.cs
index 63ffaeb..7554bf4 100644
--- a/src/Appender/RollingFileAppender.cs
+++ b/src/Appender/RollingFileAppender.cs
@@ -1493,11 +1493,24 @@ namespace log4net.Appender
 						string archiveFileBaseName = baseFileName;
 						if (!m_staticLogFileName)
 						{
+                                                    if (m_preserveLogFileNameExtension)
+                                                    {
+                                                        string extension = Path.GetExtension(archiveFileBaseName);
+                                                        string baseName = Path.GetFileNameWithoutExtension(archiveFileBaseName);
+							int lastDotIndex = baseName.LastIndexOf(".");
+							if (lastDotIndex >= 0)
+							{
+								archiveFileBaseName = baseName.Substring(0, lastDotIndex) + extension;
+							}
+                                                    }
+                                                    else
+                                                    {
 							int lastDotIndex = archiveFileBaseName.LastIndexOf(".");
 							if (lastDotIndex >= 0) 
 							{
 								archiveFileBaseName = archiveFileBaseName.Substring(0, lastDotIndex);
 							}
+                                                    }
 						}
 
 						// Delete the archive file


[2/3] logging-log4net git commit: add unit test for PR #23

Posted by bo...@apache.org.
add unit test for PR #23


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

Branch: refs/heads/master
Commit: f8b7290065f16c7fce5b54a2d2c348b16e20ab4e
Parents: ce481db
Author: Stefan Bodewig <bo...@apache.org>
Authored: Mon May 1 15:15:53 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Mon May 1 15:16:32 2017 +0200

----------------------------------------------------------------------
 tests/src/Appender/RollingFileAppenderTest.cs | 56 +++++++++++++++++++++-
 1 file changed, 55 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/f8b72900/tests/src/Appender/RollingFileAppenderTest.cs
----------------------------------------------------------------------
diff --git a/tests/src/Appender/RollingFileAppenderTest.cs b/tests/src/Appender/RollingFileAppenderTest.cs
index 6819ec2..6704777 100644
--- a/tests/src/Appender/RollingFileAppenderTest.cs
+++ b/tests/src/Appender/RollingFileAppenderTest.cs
@@ -146,7 +146,16 @@ namespace log4net.Tests.Appender
 		/// <param name="iExpectedCount"></param>
 		private static void VerifyFileCount(int iExpectedCount)
 		{
-			ArrayList alFiles = GetExistingFiles(c_fileName);
+                    VerifyFileCount(iExpectedCount, false);
+                }
+		/// <summary>
+		/// Finds the number of files that match the base file name,
+		/// and matches the result against an expected count
+		/// </summary>
+		/// <param name="iExpectedCount"></param>
+		private static void VerifyFileCount(int iExpectedCount, bool preserveLogFileNameExtension)
+		{
+			ArrayList alFiles = GetExistingFiles(c_fileName, preserveLogFileNameExtension);
 			Assert.IsNotNull(alFiles);
 			Assert.AreEqual(iExpectedCount, alFiles.Count);
 		}
@@ -192,12 +201,52 @@ namespace log4net.Tests.Appender
 			VerifyFileCount(2);
 		}
 
+            [Test]
+            public void RollingCombinedWithPreserveExtension()
+            {
+                _root = ((Repository.Hierarchy.Hierarchy)Utils.GetRepository()).Root;
+                _root.Level = Level.All;
+                PatternLayout patternLayout = new PatternLayout();
+                patternLayout.ActivateOptions();
+
+                RollingFileAppender roller = new RollingFileAppender();
+                roller.StaticLogFileName = false;
+                roller.Layout = patternLayout;
+                roller.AppendToFile = true;
+                roller.RollingStyle = RollingFileAppender.RollingMode.Composite;
+                roller.DatePattern = "dd_MM_yyyy";
+                roller.MaxSizeRollBackups = 1;
+                roller.CountDirection = 1;
+                roller.PreserveLogFileNameExtension = true;
+                roller.MaximumFileSize = "10KB";
+                roller.File = c_fileName;
+                roller.ActivateOptions();
+                _root.AddAppender(roller);
+
+                _root.Repository.Configured = true;
+
+                for (int i = 0; i < 1000; i++)
+                {
+                    StringBuilder s = new StringBuilder();
+                    for (int j = 50; j < 100; j++)
+                    {
+                        if (j > 50) {
+                            s.Append(" ");
+                        }
+                        s.Append(j);
+                    }
+                    _root.Log(Level.Debug, s.ToString(), null);
+                }
+                VerifyFileCount(2, true);
+            }
+
 		/// <summary>
 		/// Removes all test files that exist
 		/// </summary>
 		private static void DeleteTestFiles()
 		{
 			ArrayList alFiles = GetExistingFiles(c_fileName);
+                        alFiles.AddRange(GetExistingFiles(c_fileName, true));
 			foreach(string sFile in alFiles)
 			{
 				try
@@ -1938,7 +1987,12 @@ namespace log4net.Tests.Appender
 
 		private static ArrayList GetExistingFiles(string baseFilePath)
 		{
+                    return GetExistingFiles(baseFilePath, false);
+                }
+		private static ArrayList GetExistingFiles(string baseFilePath, bool preserveLogFileNameExtension)
+		{
 			RollingFileAppender appender = new RollingFileAppender();
+                        appender.PreserveLogFileNameExtension = preserveLogFileNameExtension;
 			appender.SecurityContext = NullSecurityContext.Instance;
 
 			return (ArrayList)Utils.InvokeMethod(appender, "GetExistingFiles", baseFilePath);


[3/3] logging-log4net git commit: Merge branch 'PR_23'

Posted by bo...@apache.org.
Merge branch 'PR_23'


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

Branch: refs/heads/master
Commit: e9a9bb6bb46484b7cdf6d921876375b48d5606ea
Parents: 2229b44 f8b7290
Author: Stefan Bodewig <bo...@apache.org>
Authored: Mon May 1 19:33:41 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Mon May 1 19:33:41 2017 +0200

----------------------------------------------------------------------
 src/Appender/RollingFileAppender.cs           | 13 +++++
 tests/src/Appender/RollingFileAppenderTest.cs | 56 +++++++++++++++++++++-
 2 files changed, 68 insertions(+), 1 deletion(-)
----------------------------------------------------------------------