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/07/27 15:42:26 UTC
[1/7] logging-log4net git commit: Refactor: fixed whitespaces in
RollingFileAppenderTest.cs from space to tab
Repository: logging-log4net
Updated Branches:
refs/heads/develop cd8b579fa -> aefe91afd
Refactor: fixed whitespaces in RollingFileAppenderTest.cs from space to tab
Project: http://git-wip-us.apache.org/repos/asf/logging-log4net/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4net/commit/c2d47da0
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4net/tree/c2d47da0
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4net/diff/c2d47da0
Branch: refs/heads/develop
Commit: c2d47da0902f508fa8433ac648233cf127dba8c3
Parents: cd8b579
Author: Dominik Psenner <dp...@apache.org>
Authored: Thu Jul 27 17:25:40 2017 +0200
Committer: Dominik Psenner <dp...@apache.org>
Committed: Thu Jul 27 17:25:40 2017 +0200
----------------------------------------------------------------------
tests/src/Appender/RollingFileAppenderTest.cs | 329 +++++++++++----------
1 file changed, 165 insertions(+), 164 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/c2d47da0/tests/src/Appender/RollingFileAppenderTest.cs
----------------------------------------------------------------------
diff --git a/tests/src/Appender/RollingFileAppenderTest.cs b/tests/src/Appender/RollingFileAppenderTest.cs
index 6704777..0ba3e07 100644
--- a/tests/src/Appender/RollingFileAppenderTest.cs
+++ b/tests/src/Appender/RollingFileAppenderTest.cs
@@ -146,8 +146,8 @@ namespace log4net.Tests.Appender
/// <param name="iExpectedCount"></param>
private static void VerifyFileCount(int iExpectedCount)
{
- VerifyFileCount(iExpectedCount, false);
- }
+ VerifyFileCount(iExpectedCount, false);
+ }
/// <summary>
/// Finds the number of files that match the base file name,
/// and matches the result against an expected count
@@ -201,44 +201,44 @@ 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);
- }
+ [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
@@ -246,7 +246,7 @@ namespace log4net.Tests.Appender
private static void DeleteTestFiles()
{
ArrayList alFiles = GetExistingFiles(c_fileName);
- alFiles.AddRange(GetExistingFiles(c_fileName, true));
+ alFiles.AddRange(GetExistingFiles(c_fileName, true));
foreach(string sFile in alFiles)
{
try
@@ -268,7 +268,7 @@ namespace log4net.Tests.Appender
///// <returns></returns>
//private string MakeFileName(int iFileCount)
//{
- // return MakeFileName(_fileName, iFileCount);
+ // return MakeFileName(_fileName, iFileCount);
//}
/// <summary>
@@ -317,7 +317,7 @@ namespace log4net.Tests.Appender
RollingFileAppender appender = new RollingFileAppender();
appender.Layout = layout;
appender.File = c_fileName;
- appender.Encoding = Encoding.ASCII;
+ appender.Encoding = Encoding.ASCII;
appender.MaximumFileSize = c_iMaximumFileSize.ToString();
appender.MaxSizeRollBackups = _MaxSizeRollBackups;
appender.CountDirection = _iCountDirection;
@@ -381,7 +381,7 @@ namespace log4net.Tests.Appender
}
/// <summary>
- /// Used for table-driven testing. This class holds information that can be used
+ /// Used for table-driven testing. This class holds information that can be used
/// for testing of file rolling.
/// </summary>
public class RollConditions
@@ -437,7 +437,7 @@ namespace log4net.Tests.Appender
}
/// <summary>
- /// Checks that all the expected files exist, and only the expected files. Also
+ /// Checks that all the expected files exist, and only the expected files. Also
/// verifies the length of all files against the expected length
/// </summary>
/// <param name="sBaseFileName"></param>
@@ -460,7 +460,7 @@ namespace log4net.Tests.Appender
}
else
{
- // If length is 0, file may not exist yet. If file exists, make sure length
+ // If length is 0, file may not exist yet. If file exists, make sure length
// is zero. If file doesn't exist, this is OK
if (file.Exists)
@@ -520,29 +520,29 @@ namespace log4net.Tests.Appender
//private void DumpFileEntry( RollFileEntry entry )
//{
- // System.Diagnostics.Debug.WriteLine( "\tfile name: " + entry.FileName );
- // System.Diagnostics.Debug.WriteLine( "\tfile length: " + entry.FileLength );
+ // System.Diagnostics.Debug.WriteLine( "\tfile name: " + entry.FileName );
+ // System.Diagnostics.Debug.WriteLine( "\tfile length: " + entry.FileLength );
//}
//private void DumpTableEntry( RollConditions entry )
//{
- // System.Diagnostics.Debug.WriteLine( "Pre-Conditions" );
- // foreach( RollFileEntry file in entry.GetPreLogFileEntries() )
- // {
- // DumpFileEntry( file );
- // }
- // System.Diagnostics.Debug.WriteLine( "Post-Conditions" );
- // foreach( RollFileEntry file in entry.GetPostLogFileEntries() )
- // {
- // DumpFileEntry( file );
- // }
- // // System.Diagnostics.Debug.WriteLine("");
+ // System.Diagnostics.Debug.WriteLine( "Pre-Conditions" );
+ // foreach( RollFileEntry file in entry.GetPreLogFileEntries() )
+ // {
+ // DumpFileEntry( file );
+ // }
+ // System.Diagnostics.Debug.WriteLine( "Post-Conditions" );
+ // foreach( RollFileEntry file in entry.GetPostLogFileEntries() )
+ // {
+ // DumpFileEntry( file );
+ // }
+ // // System.Diagnostics.Debug.WriteLine("");
//}
/// <summary>
/// Runs through all table entries, logging messages. Before each message is logged,
/// pre-conditions are checked to ensure the expected files exist and they are the
- /// expected size. After logging, verifies the same.
+ /// expected size. After logging, verifies the same.
/// </summary>
/// <param name="sBaseFileName"></param>
/// <param name="entries"></param>
@@ -553,19 +553,19 @@ namespace log4net.Tests.Appender
{
RollConditions entry = entries[i];
- // System.Diagnostics.Debug.WriteLine( i + ": Entry " + i + " pre/post conditions");
- // DumpTableEntry( entry );
- // System.Diagnostics.Debug.WriteLine( i + ": Testing entry pre-conditions");
+ // System.Diagnostics.Debug.WriteLine( i + ": Entry " + i + " pre/post conditions");
+ // DumpTableEntry( entry );
+ // System.Diagnostics.Debug.WriteLine( i + ": Testing entry pre-conditions");
VerifyPreConditions(sBaseFileName, entry);
- // System.Diagnostics.Debug.WriteLine( i + ": Logging message");
+ // System.Diagnostics.Debug.WriteLine( i + ": Logging message");
LogMessage(entry, sMessageToLog);
- // System.Diagnostics.Debug.WriteLine( i + ": Testing entry post-conditions");
+ // System.Diagnostics.Debug.WriteLine( i + ": Testing entry post-conditions");
VerifyPostConditions(sBaseFileName, entry);
- // System.Diagnostics.Debug.WriteLine( i + ": Finished validating entry\n");
+ // System.Diagnostics.Debug.WriteLine( i + ": Finished validating entry\n");
}
}
- private static readonly int s_Newline_Length = Environment.NewLine.Length;
+ private static readonly int s_Newline_Length = Environment.NewLine.Length;
/// <summary>
/// Returns the number of bytes logged per message, including
@@ -575,7 +575,7 @@ namespace log4net.Tests.Appender
/// <returns></returns>
private static int TotalMessageLength(string sMessage)
{
- return sMessage.Length + s_Newline_Length;
+ return sMessage.Length + s_Newline_Length;
}
/// <summary>
@@ -660,28 +660,28 @@ namespace log4net.Tests.Appender
///// <returns></returns>
//private RollFileEntry[] MakeBackupFileEntriesForPreCondition( string sBackupGroups, RollingStats stats )
//{
- // if (0 == stats.NumberOfFileRolls )
- // {
- // return null; // first round has no previous backups
- // }
- // string sGroup;
- // if (0 == stats.MessagesThisFile )
- // {
- // // first file has special pattern...since rolling doesn't occur when message
- // // is logged, rather before next message is logged.
- // if (stats.NumberOfFileRolls <= 1 )
- // {
- // return null;
- // }
- // // Use backup files from previous round. The minus 2 is because we have already
- // // rolled, and the first round uses null instead of the string
- // sGroup = GetBackupGroup( sBackupGroups, stats.NumberOfFileRolls-2 );
- // }
- // else
- // {
- // sGroup = GetBackupGroup( sBackupGroups, stats.NumberOfFileRolls-1 );
- // }
- // return MakeBackupFileEntriesFromBackupGroup( sGroup, stats.MaximumFileSize );
+ // if (0 == stats.NumberOfFileRolls )
+ // {
+ // return null; // first round has no previous backups
+ // }
+ // string sGroup;
+ // if (0 == stats.MessagesThisFile )
+ // {
+ // // first file has special pattern...since rolling doesn't occur when message
+ // // is logged, rather before next message is logged.
+ // if (stats.NumberOfFileRolls <= 1 )
+ // {
+ // return null;
+ // }
+ // // Use backup files from previous round. The minus 2 is because we have already
+ // // rolled, and the first round uses null instead of the string
+ // sGroup = GetBackupGroup( sBackupGroups, stats.NumberOfFileRolls-2 );
+ // }
+ // else
+ // {
+ // sGroup = GetBackupGroup( sBackupGroups, stats.NumberOfFileRolls-1 );
+ // }
+ // return MakeBackupFileEntriesFromBackupGroup( sGroup, stats.MaximumFileSize );
//}
/// <summary>
@@ -940,21 +940,21 @@ namespace log4net.Tests.Appender
/// Uses the externally defined rolling table to verify rolling names/sizes
/// </summary>
/// <remarks>
- /// Pattern is: check pre-conditions. Log messages, checking size of current file.
+ /// Pattern is: check pre-conditions. Log messages, checking size of current file.
/// when size exceeds limit, check post conditions. Can determine from message the
/// number of messages N that will cause a roll to occur. Challenge is to verify the
/// expected files, their sizes, and the names. For a message of length L, the backups
/// will be of size (N * L), and the current file will be of size (K * L), where K is
/// the number of messages that have been logged to this file.
///
- /// File sizes can be checked algorithmically.
+ /// File sizes can be checked algorithmically.
///
/// File names are generated using a table driven algorithm, where a number is turned into
/// the actual filename.
///
/// The entries are comma-separated, with spaces between the names. Each comma indicates
/// a 'roll', and the group between commas indicates the numbers for all backup files that
- /// occur as a result of the roll. It is assumed that no backup files exist before a roll
+ /// occur as a result of the roll. It is assumed that no backup files exist before a roll
/// occurs
/// </remarks>
/// <param name="table"></param>
@@ -1693,72 +1693,72 @@ namespace log4net.Tests.Appender
}
#if !NETCF
- /// <summary>
- /// Verifies that attempting to log to a locked file fails gracefully
- /// </summary>
- [Test]
- public void TestInterProcessLockFails() {
- String filename = "test.log";
-
- FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None);
- fs.Write(Encoding.ASCII.GetBytes("Test"), 0, 4);
-
- SilentErrorHandler sh = new SilentErrorHandler();
- ILogger log = CreateLogger(filename, new FileAppender.InterProcessLock(), sh);
- log.Log(GetType(), Level.Info, "This is a message", null);
- log.Log(GetType(), Level.Info, "This is a message 2", null);
- DestroyLogger();
- fs.Close();
-
- AssertFileEquals(filename, "Test");
- Assert.AreEqual("Unable to acquire lock on file", sh.Message.Substring(0, 30), "Expecting an error message");
- }
-
- /// <summary>
- /// Verifies that attempting to log to a locked file recovers if the lock is released
- /// </summary>
- [Test]
- public void TestInterProcessLockRecovers() {
- String filename = "test.log";
-
- FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None);
- fs.Write(Encoding.ASCII.GetBytes("Test"), 0, 4);
-
- SilentErrorHandler sh = new SilentErrorHandler();
- ILogger log = CreateLogger(filename, new FileAppender.InterProcessLock(), sh);
- log.Log(GetType(), Level.Info, "This is a message", null);
- fs.Close();
- log.Log(GetType(), Level.Info, "This is a message 2", null);
- DestroyLogger();
-
- AssertFileEquals(filename, "This is a message 2" + Environment.NewLine);
- Assert.AreEqual("Unable to acquire lock on file", sh.Message.Substring(0, 30), "Expecting an error message");
- }
-
- /// <summary>
- /// Verifies that attempting to log to a file with InterProcessLock really locks the file
- /// </summary>
- [Test]
- public void TestInterProcessLockUnlocks() {
- String filename = "test.log";
- bool locked;
-
- SilentErrorHandler sh = new SilentErrorHandler();
- ILogger log = CreateLogger(filename, new FileAppender.InterProcessLock(), sh);
- log.Log(GetType(), Level.Info, "This is a message", null);
-
- locked = true;
- FileStream fs = new FileStream(filename, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
- fs.Write(Encoding.ASCII.GetBytes("Test" + Environment.NewLine), 0, 4 + Environment.NewLine.Length);
- fs.Close();
-
- log.Log(GetType(), Level.Info, "This is a message 2", null);
- DestroyLogger();
-
- Assert.IsTrue(locked, "File was not locked");
- AssertFileEquals(filename, "This is a message" + Environment.NewLine + "Test" + Environment.NewLine + "This is a message 2" + Environment.NewLine);
- Assert.AreEqual("", sh.Message, "Unexpected error message");
- }
+ /// <summary>
+ /// Verifies that attempting to log to a locked file fails gracefully
+ /// </summary>
+ [Test]
+ public void TestInterProcessLockFails() {
+ String filename = "test.log";
+
+ FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None);
+ fs.Write(Encoding.ASCII.GetBytes("Test"), 0, 4);
+
+ SilentErrorHandler sh = new SilentErrorHandler();
+ ILogger log = CreateLogger(filename, new FileAppender.InterProcessLock(), sh);
+ log.Log(GetType(), Level.Info, "This is a message", null);
+ log.Log(GetType(), Level.Info, "This is a message 2", null);
+ DestroyLogger();
+ fs.Close();
+
+ AssertFileEquals(filename, "Test");
+ Assert.AreEqual("Unable to acquire lock on file", sh.Message.Substring(0, 30), "Expecting an error message");
+ }
+
+ /// <summary>
+ /// Verifies that attempting to log to a locked file recovers if the lock is released
+ /// </summary>
+ [Test]
+ public void TestInterProcessLockRecovers() {
+ String filename = "test.log";
+
+ FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None);
+ fs.Write(Encoding.ASCII.GetBytes("Test"), 0, 4);
+
+ SilentErrorHandler sh = new SilentErrorHandler();
+ ILogger log = CreateLogger(filename, new FileAppender.InterProcessLock(), sh);
+ log.Log(GetType(), Level.Info, "This is a message", null);
+ fs.Close();
+ log.Log(GetType(), Level.Info, "This is a message 2", null);
+ DestroyLogger();
+
+ AssertFileEquals(filename, "This is a message 2" + Environment.NewLine);
+ Assert.AreEqual("Unable to acquire lock on file", sh.Message.Substring(0, 30), "Expecting an error message");
+ }
+
+ /// <summary>
+ /// Verifies that attempting to log to a file with InterProcessLock really locks the file
+ /// </summary>
+ [Test]
+ public void TestInterProcessLockUnlocks() {
+ String filename = "test.log";
+ bool locked;
+
+ SilentErrorHandler sh = new SilentErrorHandler();
+ ILogger log = CreateLogger(filename, new FileAppender.InterProcessLock(), sh);
+ log.Log(GetType(), Level.Info, "This is a message", null);
+
+ locked = true;
+ FileStream fs = new FileStream(filename, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
+ fs.Write(Encoding.ASCII.GetBytes("Test" + Environment.NewLine), 0, 4 + Environment.NewLine.Length);
+ fs.Close();
+
+ log.Log(GetType(), Level.Info, "This is a message 2", null);
+ DestroyLogger();
+
+ Assert.IsTrue(locked, "File was not locked");
+ AssertFileEquals(filename, "This is a message" + Environment.NewLine + "Test" + Environment.NewLine + "This is a message 2" + Environment.NewLine);
+ Assert.AreEqual("", sh.Message, "Unexpected error message");
+ }
/// <summary>
/// Verifies that rolling file works
@@ -1782,7 +1782,7 @@ namespace log4net.Tests.Appender
}
#endif
- /// <summary>
+ /// <summary>
/// Verify that the default LockModel is ExclusiveLock, to maintain backwards compatibility with previous behaviour
/// </summary>
[Test]
@@ -1910,7 +1910,7 @@ namespace log4net.Tests.Appender
// 2 = file.log.1
// 3 = file.log.2
if (0 == iBackups ||
- 1 == iBackups)
+ 1 == iBackups)
{
Assert.AreEqual(0, GetFieldCurSizeRollBackups(rfa));
}
@@ -1987,12 +1987,13 @@ namespace log4net.Tests.Appender
private static ArrayList GetExistingFiles(string baseFilePath)
{
- return GetExistingFiles(baseFilePath, false);
- }
+ return GetExistingFiles(baseFilePath, false);
+ }
+
private static ArrayList GetExistingFiles(string baseFilePath, bool preserveLogFileNameExtension)
{
RollingFileAppender appender = new RollingFileAppender();
- appender.PreserveLogFileNameExtension = preserveLogFileNameExtension;
+ appender.PreserveLogFileNameExtension = preserveLogFileNameExtension;
appender.SecurityContext = NullSecurityContext.Instance;
return (ArrayList)Utils.InvokeMethod(appender, "GetExistingFiles", baseFilePath);
[2/7] logging-log4net git commit: Refactor: removed trailing
whitespaces from RollingFileAppenderTest.cs
Posted by dp...@apache.org.
Refactor: removed trailing whitespaces from RollingFileAppenderTest.cs
Project: http://git-wip-us.apache.org/repos/asf/logging-log4net/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4net/commit/c6391aea
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4net/tree/c6391aea
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4net/diff/c6391aea
Branch: refs/heads/develop
Commit: c6391aea18a6a4124f46b11e33feec6910a54dce
Parents: c2d47da
Author: Dominik Psenner <dp...@apache.org>
Authored: Thu Jul 27 17:29:52 2017 +0200
Committer: Dominik Psenner <dp...@apache.org>
Committed: Thu Jul 27 17:29:52 2017 +0200
----------------------------------------------------------------------
tests/src/Appender/RollingFileAppenderTest.cs | 63 +++++++++++-----------
1 file changed, 31 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/c6391aea/tests/src/Appender/RollingFileAppenderTest.cs
----------------------------------------------------------------------
diff --git a/tests/src/Appender/RollingFileAppenderTest.cs b/tests/src/Appender/RollingFileAppenderTest.cs
index 0ba3e07..25d4fa5 100644
--- a/tests/src/Appender/RollingFileAppenderTest.cs
+++ b/tests/src/Appender/RollingFileAppenderTest.cs
@@ -1,10 +1,10 @@
#region Apache License
//
-// Licensed to the Apache Software Foundation (ASF) under one or more
+// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
+// this work for additional information regarding copyright ownership.
// The ASF licenses this file to you under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
+// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
@@ -481,8 +481,8 @@ namespace log4net.Tests.Appender
}
/// <summary>
- /// Called before logging a message to check that all the expected files exist,
- /// and only the expected files. Also verifies the length of all files against
+ /// Called before logging a message to check that all the expected files exist,
+ /// and only the expected files. Also verifies the length of all files against
/// the expected length
/// </summary>
/// <param name="sBaseFileName"></param>
@@ -493,8 +493,8 @@ namespace log4net.Tests.Appender
}
/// <summary>
- /// Called after logging a message to check that all the expected files exist,
- /// and only the expected files. Also verifies the length of all files against
+ /// Called after logging a message to check that all the expected files exist,
+ /// and only the expected files. Also verifies the length of all files against
/// the expected length
/// </summary>
/// <param name="sBaseFileName"></param>
@@ -505,7 +505,7 @@ namespace log4net.Tests.Appender
}
/// <summary>
- /// Logs a message, verifying the expected message counts against the
+ /// Logs a message, verifying the expected message counts against the
/// current running totals.
/// </summary>
/// <param name="entry"></param>
@@ -671,7 +671,7 @@ namespace log4net.Tests.Appender
// // is logged, rather before next message is logged.
// if (stats.NumberOfFileRolls <= 1 )
// {
- // return null;
+ // return null;
// }
// // Use backup files from previous round. The minus 2 is because we have already
// // rolled, and the first round uses null instead of the string
@@ -896,8 +896,8 @@ namespace log4net.Tests.Appender
/// <summary>
/// This routine takes a list of backup file names and a message that will be logged
- /// repeatedly, and generates a collection of objects containing pre-condition and
- /// post-condition information. This pre/post information shows the names and expected
+ /// repeatedly, and generates a collection of objects containing pre-condition and
+ /// post-condition information. This pre/post information shows the names and expected
/// file sizes for all files just before and just after a message is logged.
/// </summary>
/// <param name="sTestMessage">A message to log repeatedly</param>
@@ -947,14 +947,14 @@ namespace log4net.Tests.Appender
/// will be of size (N * L), and the current file will be of size (K * L), where K is
/// the number of messages that have been logged to this file.
///
- /// File sizes can be checked algorithmically.
- ///
+ /// File sizes can be checked algorithmically.
+ ///
/// File names are generated using a table driven algorithm, where a number is turned into
/// the actual filename.
- ///
+ ///
/// The entries are comma-separated, with spaces between the names. Each comma indicates
/// a 'roll', and the group between commas indicates the numbers for all backup files that
- /// occur as a result of the roll. It is assumed that no backup files exist before a roll
+ /// occur as a result of the roll. It is assumed that no backup files exist before a roll
/// occurs
/// </remarks>
/// <param name="table"></param>
@@ -985,7 +985,7 @@ namespace log4net.Tests.Appender
_iCountDirection = +1;
//
- // Log 30 messages. This is 5 groups, 6 checks per group ( 0, 100, 200, 300, 400, 500
+ // Log 30 messages. This is 5 groups, 6 checks per group ( 0, 100, 200, 300, 400, 500
// bytes for current file as messages are logged.
//
int iMessagesToLog = 30;
@@ -996,7 +996,7 @@ namespace log4net.Tests.Appender
/// <summary>
/// Validates rolling using an infinite number of backup files, with
/// count direction set to up, so that newer files have higher counts.
- /// Newest = N, Oldest = 1, where N is the number of times rolling has
+ /// Newest = N, Oldest = 1, where N is the number of times rolling has
/// occurred.
/// </summary>
[Test]
@@ -1019,7 +1019,7 @@ namespace log4net.Tests.Appender
_MaxSizeRollBackups = -1;
//
- // Log 30 messages. This is 5 groups, 6 checks per group ( 0, 100, 200, 300, 400, 500
+ // Log 30 messages. This is 5 groups, 6 checks per group ( 0, 100, 200, 300, 400, 500
// bytes for current file as messages are logged.
//
int iMessagesToLog = 30;
@@ -1052,7 +1052,7 @@ namespace log4net.Tests.Appender
_MaxSizeRollBackups = 0;
//
- // Log 30 messages. This is 5 groups, 6 checks per group ( 0, 100, 200, 300, 400, 500
+ // Log 30 messages. This is 5 groups, 6 checks per group ( 0, 100, 200, 300, 400, 500
// bytes for current file as messages are logged.
//
int iMessagesToLog = 30;
@@ -1081,7 +1081,7 @@ namespace log4net.Tests.Appender
_iCountDirection = -1;
//
- // Log 30 messages. This is 5 groups, 6 checks per group ( 0, 100, 200, 300, 400, 500
+ // Log 30 messages. This is 5 groups, 6 checks per group ( 0, 100, 200, 300, 400, 500
// bytes for current file as messages are logged.
//
int iMessagesToLog = 30;
@@ -1115,7 +1115,7 @@ namespace log4net.Tests.Appender
_MaxSizeRollBackups = -1;
//
- // Log 30 messages. This is 5 groups, 6 checks per group ( 0, 100, 200, 300, 400, 500
+ // Log 30 messages. This is 5 groups, 6 checks per group ( 0, 100, 200, 300, 400, 500
// bytes for current file as messages are logged.
//
int iMessagesToLog = 30;
@@ -1148,7 +1148,7 @@ namespace log4net.Tests.Appender
_MaxSizeRollBackups = 0;
//
- // Log 30 messages. This is 5 groups, 6 checks per group ( 0, 100, 200, 300, 400, 500
+ // Log 30 messages. This is 5 groups, 6 checks per group ( 0, 100, 200, 300, 400, 500
// bytes for current file as messages are logged.
//
int iMessagesToLog = 30;
@@ -1773,7 +1773,6 @@ namespace log4net.Tests.Appender
Assert.DoesNotThrow(delegate { log.Log(GetType(), Level.Info, "A", null); });
Assert.DoesNotThrow(delegate { log.Log(GetType(), Level.Info, "A", null); });
-
DestroyLogger();
AssertFileEquals(filename, "A" + Environment.NewLine);
@@ -1828,10 +1827,10 @@ namespace log4net.Tests.Appender
/// <summary>
/// Turns a string of comma separated numbers into a collection of filenames
- /// generated from the numbers.
- ///
+ /// generated from the numbers.
+ ///
/// Defaults to filename in _fileName variable.
- ///
+ ///
/// </summary>
/// <param name="sFileNumbers">Comma separated list of numbers for counted file names</param>
/// <returns></returns>
@@ -1843,7 +1842,7 @@ namespace log4net.Tests.Appender
/// <summary>
/// Turns a string of comma separated numbers into a collection of filenames
/// generated from the numbers
- ///
+ ///
/// Uses the input filename.
/// </summary>
/// <param name="sFileName">Name of file to combine with numbers when generating counted file names</param>
@@ -1941,7 +1940,7 @@ namespace log4net.Tests.Appender
}
/// <summary>
- ///
+ ///
/// </summary>
[Test, Ignore("Not Implemented: Want to test counted files limited up, to see that others are ?? ignored? deleted?")]
public void TestInitialization3()
@@ -1949,7 +1948,7 @@ namespace log4net.Tests.Appender
}
/// <summary>
- ///
+ ///
/// </summary>
[Test, Ignore("Not Implemented: Want to test counted files limited down, to see that others are ?? ignored? deleted?")]
public void TestInitialization4()
@@ -1957,7 +1956,7 @@ namespace log4net.Tests.Appender
}
/// <summary>
- ///
+ ///
/// </summary>
[Test, Ignore("Not Implemented: Want to test dated files with a limit, to see that others are ?? ignored? deleted?")]
public void TestInitialization5()
@@ -1965,7 +1964,7 @@ namespace log4net.Tests.Appender
}
/// <summary>
- ///
+ ///
/// </summary>
[Test, Ignore("Not Implemented: Want to test dated files with no limit, to see that others are ?? ignored? deleted?")]
public void TestInitialization6()
@@ -1973,7 +1972,7 @@ namespace log4net.Tests.Appender
}
/// <summary>
- ///
+ ///
/// </summary>
[Test, Ignore("Not Implemented: Want to test dated files with mixed dates existing, to see that other dates do not matter")]
public void TestInitialization7()
[7/7] logging-log4net git commit: Refactor: fixed all comments in
RollingFileAppender.cs to match `// [a-zA-Z]`
Posted by dp...@apache.org.
Refactor: fixed all comments in RollingFileAppender.cs to match `// [a-zA-Z]`
Project: http://git-wip-us.apache.org/repos/asf/logging-log4net/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4net/commit/aefe91af
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4net/tree/aefe91af
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4net/diff/aefe91af
Branch: refs/heads/develop
Commit: aefe91afd550811a1b26f9ce9414388874ae598a
Parents: ae65cb8
Author: Dominik Psenner <dp...@apache.org>
Authored: Thu Jul 27 17:41:10 2017 +0200
Committer: Dominik Psenner <dp...@apache.org>
Committed: Thu Jul 27 17:41:10 2017 +0200
----------------------------------------------------------------------
src/Appender/RollingFileAppender.cs | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/aefe91af/src/Appender/RollingFileAppender.cs
----------------------------------------------------------------------
diff --git a/src/Appender/RollingFileAppender.cs b/src/Appender/RollingFileAppender.cs
index 2963db6..1bcf0e0 100644
--- a/src/Appender/RollingFileAppender.cs
+++ b/src/Appender/RollingFileAppender.cs
@@ -984,8 +984,8 @@ namespace log4net.Appender
}
catch(FormatException)
{
- //this happens when file.log -> file.log.yyyy-MM-dd which is normal
- //when staticLogFileName == false
+ // This happens when file.log -> file.log.yyyy-MM-dd which is normal
+ // when staticLogFileName == false
LogLog.Debug(declaringType, "Encountered a backup file not ending in .x ["+curFileName+"]");
}
}
@@ -1206,9 +1206,9 @@ namespace log4net.Appender
return;
}
- //is the new file name equivalent to the 'current' one
- //something has gone wrong if we hit this -- we should only
- //roll over if the new file will be different from the old
+ // is the new file name equivalent to the 'current' one
+ // something has gone wrong if we hit this -- we should only
+ // roll over if the new file will be different from the old
string dateFormat = m_now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo);
if (m_scheduledFilename.Equals(CombinePath(File, dateFormat)))
{
@@ -1222,7 +1222,7 @@ namespace log4net.Appender
this.CloseFile();
}
- //we may have to roll over a large number of backups here
+ // we may have to roll over a large number of backups here
for (int i = 1; i <= m_curSizeRollBackups; i++)
{
string from = CombinePath(File, "." + i);
@@ -1233,10 +1233,10 @@ namespace log4net.Appender
RollFile(File, m_scheduledFilename);
}
- //We've cleared out the old date and are ready for the new
+ // We've cleared out the old date and are ready for the new
m_curSizeRollBackups = 0;
- //new scheduled name
+ // new scheduled name
m_scheduledFilename = CombinePath(File, m_now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo));
if (fileIsOpen)
@@ -1463,10 +1463,10 @@ namespace log4net.Appender
}
else
{
- //countDirection >= 0
+ // countDirection >= 0
if (m_curSizeRollBackups >= m_maxSizeRollBackups && m_maxSizeRollBackups > 0)
{
- //delete the first and keep counting up.
+ // delete the first and keep counting up.
int oldestFileIndex = m_curSizeRollBackups - m_maxSizeRollBackups;
// If static then there is 1 file without a number, therefore 1 less archive
[6/7] logging-log4net git commit: Refactor: removed code in
RollingFileAppender.cs that is commented out
Posted by dp...@apache.org.
Refactor: removed code in RollingFileAppender.cs that is commented out
Project: http://git-wip-us.apache.org/repos/asf/logging-log4net/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4net/commit/ae65cb85
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4net/tree/ae65cb85
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4net/diff/ae65cb85
Branch: refs/heads/develop
Commit: ae65cb85cda07827f33257af5ea474631827a264
Parents: 89d3820
Author: Dominik Psenner <dp...@apache.org>
Authored: Thu Jul 27 17:39:47 2017 +0200
Committer: Dominik Psenner <dp...@apache.org>
Committed: Thu Jul 27 17:39:47 2017 +0200
----------------------------------------------------------------------
src/Appender/RollingFileAppender.cs | 12 ------------
1 file changed, 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/ae65cb85/src/Appender/RollingFileAppender.cs
----------------------------------------------------------------------
diff --git a/src/Appender/RollingFileAppender.cs b/src/Appender/RollingFileAppender.cs
index fcdd13a..2963db6 100644
--- a/src/Appender/RollingFileAppender.cs
+++ b/src/Appender/RollingFileAppender.cs
@@ -929,18 +929,6 @@ namespace log4net.Appender
return;
}
- /*
- if (m_staticLogFileName)
- {
- int endLength = curFileName.Length - index;
- if (baseFile.Length + endLength != curFileName.Length)
- {
- // file is probably scheduledFilename + .x so I don't care
- return;
- }
- }
- */
-
// Only look for files in the current roll point
if (m_rollDate && !m_staticLogFileName)
{
[3/7] logging-log4net git commit: Refactor: removed code in
RollingFileAppenderTest.cs that is commented out
Posted by dp...@apache.org.
Refactor: removed code in RollingFileAppenderTest.cs that is commented out
After all we have the file versioned and can bring that code back anytime
we want.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4net/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4net/commit/3c6ec8bb
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4net/tree/3c6ec8bb
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4net/diff/3c6ec8bb
Branch: refs/heads/develop
Commit: 3c6ec8bb87140be7707a02ed43aed425cee0a2b9
Parents: c6391ae
Author: Dominik Psenner <dp...@apache.org>
Authored: Thu Jul 27 17:31:10 2017 +0200
Committer: Dominik Psenner <dp...@apache.org>
Committed: Thu Jul 27 17:31:10 2017 +0200
----------------------------------------------------------------------
tests/src/Appender/RollingFileAppenderTest.cs | 55 ----------------------
1 file changed, 55 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/3c6ec8bb/tests/src/Appender/RollingFileAppenderTest.cs
----------------------------------------------------------------------
diff --git a/tests/src/Appender/RollingFileAppenderTest.cs b/tests/src/Appender/RollingFileAppenderTest.cs
index 25d4fa5..07ebfec 100644
--- a/tests/src/Appender/RollingFileAppenderTest.cs
+++ b/tests/src/Appender/RollingFileAppenderTest.cs
@@ -518,27 +518,6 @@ namespace log4net.Tests.Appender
_iMessagesLoggedThisFile++;
}
- //private void DumpFileEntry( RollFileEntry entry )
- //{
- // System.Diagnostics.Debug.WriteLine( "\tfile name: " + entry.FileName );
- // System.Diagnostics.Debug.WriteLine( "\tfile length: " + entry.FileLength );
- //}
-
- //private void DumpTableEntry( RollConditions entry )
- //{
- // System.Diagnostics.Debug.WriteLine( "Pre-Conditions" );
- // foreach( RollFileEntry file in entry.GetPreLogFileEntries() )
- // {
- // DumpFileEntry( file );
- // }
- // System.Diagnostics.Debug.WriteLine( "Post-Conditions" );
- // foreach( RollFileEntry file in entry.GetPostLogFileEntries() )
- // {
- // DumpFileEntry( file );
- // }
- // // System.Diagnostics.Debug.WriteLine("");
- //}
-
/// <summary>
/// Runs through all table entries, logging messages. Before each message is logged,
/// pre-conditions are checked to ensure the expected files exist and they are the
@@ -650,40 +629,6 @@ namespace log4net.Tests.Appender
return sGroups[iGroup];
}
- ///// <summary>
- ///// Builds a collection of file entries based on the file names
- ///// specified in a groups string and the max file size from the
- ///// stats object
- ///// </summary>
- ///// <param name="sBackupGroups"></param>
- ///// <param name="stats"></param>
- ///// <returns></returns>
- //private RollFileEntry[] MakeBackupFileEntriesForPreCondition( string sBackupGroups, RollingStats stats )
- //{
- // if (0 == stats.NumberOfFileRolls )
- // {
- // return null; // first round has no previous backups
- // }
- // string sGroup;
- // if (0 == stats.MessagesThisFile )
- // {
- // // first file has special pattern...since rolling doesn't occur when message
- // // is logged, rather before next message is logged.
- // if (stats.NumberOfFileRolls <= 1 )
- // {
- // return null;
- // }
- // // Use backup files from previous round. The minus 2 is because we have already
- // // rolled, and the first round uses null instead of the string
- // sGroup = GetBackupGroup( sBackupGroups, stats.NumberOfFileRolls-2 );
- // }
- // else
- // {
- // sGroup = GetBackupGroup( sBackupGroups, stats.NumberOfFileRolls-1 );
- // }
- // return MakeBackupFileEntriesFromBackupGroup( sGroup, stats.MaximumFileSize );
- //}
-
/// <summary>
/// Builds a collection of file entries based on the file names
/// specified in a groups string and the max file size from the
[4/7] logging-log4net git commit: Refactor: removed trailing
whitespace from RollingFileAppender.cs
Posted by dp...@apache.org.
Refactor: removed trailing whitespace from RollingFileAppender.cs
Project: http://git-wip-us.apache.org/repos/asf/logging-log4net/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4net/commit/c8e5130c
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4net/tree/c8e5130c
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4net/diff/c8e5130c
Branch: refs/heads/develop
Commit: c8e5130cde5ab416a2c7878ee8979329942d4ed0
Parents: 3c6ec8b
Author: Dominik Psenner <dp...@apache.org>
Authored: Thu Jul 27 17:36:10 2017 +0200
Committer: Dominik Psenner <dp...@apache.org>
Committed: Thu Jul 27 17:36:10 2017 +0200
----------------------------------------------------------------------
src/Appender/RollingFileAppender.cs | 282 +++++++++++++++----------------
1 file changed, 141 insertions(+), 141 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/c8e5130c/src/Appender/RollingFileAppender.cs
----------------------------------------------------------------------
diff --git a/src/Appender/RollingFileAppender.cs b/src/Appender/RollingFileAppender.cs
index 7554bf4..a56766b 100644
--- a/src/Appender/RollingFileAppender.cs
+++ b/src/Appender/RollingFileAppender.cs
@@ -1,10 +1,10 @@
#region Apache License
//
-// Licensed to the Apache Software Foundation (ASF) under one or more
+// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
+// this work for additional information regarding copyright ownership.
// The ASF licenses this file to you under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
+// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
@@ -32,12 +32,12 @@ namespace log4net.Appender
// The following sounds good, and I though it was the case, but after
// further testing on Windows I have not been able to confirm it.
- /// On the Windows platform if another process has a write lock on the file
+ /// On the Windows platform if another process has a write lock on the file
/// that is to be deleted, but allows shared read access to the file then the
- /// file can be moved, but cannot be deleted. If the other process also allows
- /// shared delete access to the file then the file will be deleted once that
+ /// file can be moved, but cannot be deleted. If the other process also allows
+ /// shared delete access to the file then the file will be deleted once that
/// process closes the file. If it is necessary to open the log file or any
- /// of the backup files outside of this appender for either read or
+ /// of the backup files outside of this appender for either read or
/// write access please ensure that read and delete share modes are enabled.
#endif
@@ -69,34 +69,34 @@ namespace log4net.Appender
/// <item>Infinite number of backups by file size <see cref="MaxSizeRollBackups"/></item>
/// </list>
/// </para>
- ///
+ ///
/// <note>
/// <para>
- /// For large or infinite numbers of backup files a <see cref="CountDirection"/>
+ /// For large or infinite numbers of backup files a <see cref="CountDirection"/>
/// greater than zero is highly recommended, otherwise all the backup files need
/// to be renamed each time a new backup is created.
/// </para>
/// <para>
- /// When Date/Time based rolling is used setting <see cref="StaticLogFileName"/>
+ /// When Date/Time based rolling is used setting <see cref="StaticLogFileName"/>
/// to <see langword="true"/> will reduce the number of file renamings to few or none.
/// </para>
/// </note>
- ///
+ ///
/// <note type="caution">
/// <para>
/// Changing <see cref="StaticLogFileName"/> or <see cref="CountDirection"/> without clearing
- /// the log file directory of backup files will cause unexpected and unwanted side effects.
+ /// the log file directory of backup files will cause unexpected and unwanted side effects.
/// </para>
/// </note>
- ///
+ ///
/// <para>
/// If Date/Time based rolling is enabled this appender will attempt to roll existing files
/// in the directory without a Date/Time tag based on the last write date of the base log file.
- /// The appender only rolls the log file when a message is logged. If Date/Time based rolling
+ /// The appender only rolls the log file when a message is logged. If Date/Time based rolling
/// is enabled then the appender will not roll the log file at the Date/Time boundary but
/// at the point when the next message is logged after the boundary has been crossed.
/// </para>
- ///
+ ///
/// <para>
/// The <see cref="RollingFileAppender"/> extends the <see cref="FileAppender"/> and
/// has the same behavior when opening the log file.
@@ -111,7 +111,7 @@ namespace log4net.Appender
/// When rolling a backup file necessitates deleting an older backup file the
/// file to be deleted is moved to a temporary name before being deleted.
/// </para>
- ///
+ ///
/// <note type="caution">
/// <para>
/// A maximum number of backup files when rolling on date/time boundaries is not supported.
@@ -232,7 +232,7 @@ namespace log4net.Appender
/// Default constructor.
/// </para>
/// </remarks>
- public RollingFileAppender()
+ public RollingFileAppender()
{
}
@@ -261,7 +261,7 @@ namespace log4net.Appender
#if !NET_1_0 && !CLI_1_0 && !NETCF
/// <summary>
/// Gets or sets the strategy for determining the current date and time. The default
- /// implementation is to use LocalDateTime which internally calls through to DateTime.Now.
+ /// implementation is to use LocalDateTime which internally calls through to DateTime.Now.
/// DateTime.UtcNow may be used on frameworks newer than .NET 1.0 by specifying
/// <see cref="RollingFileAppender.UniversalDateTime"/>.
/// </summary>
@@ -273,7 +273,7 @@ namespace log4net.Appender
/// Gets or sets the <see cref="RollingFileAppender.IDateTime"/> used to return the current date and time.
/// </para>
/// <para>
- /// There are two built strategies for determining the current date and time,
+ /// There are two built strategies for determining the current date and time,
/// <see cref="RollingFileAppender.LocalDateTime"/>
/// and <see cref="RollingFileAppender.UniversalDateTime"/>.
/// </para>
@@ -284,7 +284,7 @@ namespace log4net.Appender
#else
/// <summary>
/// Gets or sets the strategy for determining the current date and time. The default
- /// implementation is to use LocalDateTime which internally calls through to DateTime.Now.
+ /// implementation is to use LocalDateTime which internally calls through to DateTime.Now.
/// </summary>
/// <value>
/// An implementation of the <see cref="RollingFileAppender.IDateTime"/> interface which returns the current date and time.
@@ -309,12 +309,12 @@ namespace log4net.Appender
/// when rolling over on date.
/// </summary>
/// <value>
- /// The date pattern to be used for generating file names when rolling
+ /// The date pattern to be used for generating file names when rolling
/// over on date.
/// </value>
/// <remarks>
/// <para>
- /// Takes a string in the same format as expected by
+ /// Takes a string in the same format as expected by
/// <see cref="log4net.DateFormatter.SimpleDateFormatter" />.
/// </para>
/// <para>
@@ -327,7 +327,7 @@ namespace log4net.Appender
get { return m_datePattern; }
set { m_datePattern = value; }
}
-
+
/// <summary>
/// Gets or sets the maximum number of backup files that are kept before
/// the oldest is erased.
@@ -338,16 +338,16 @@ namespace log4net.Appender
/// </value>
/// <remarks>
/// <para>
- /// If set to zero, then there will be no backup files and the log file
- /// will be truncated when it reaches <see cref="MaxFileSize"/>.
+ /// If set to zero, then there will be no backup files and the log file
+ /// will be truncated when it reaches <see cref="MaxFileSize"/>.
/// </para>
/// <para>
- /// If a negative number is supplied then no deletions will be made. Note
- /// that this could result in very slow performance as a large number of
+ /// If a negative number is supplied then no deletions will be made. Note
+ /// that this could result in very slow performance as a large number of
/// files are rolled over unless <see cref="CountDirection"/> is used.
/// </para>
/// <para>
- /// The maximum applies to <b>each</b> time based group of files and
+ /// The maximum applies to <b>each</b> time based group of files and
/// <b>not</b> the total.
/// </para>
/// </remarks>
@@ -356,20 +356,20 @@ namespace log4net.Appender
get { return m_maxSizeRollBackups; }
set { m_maxSizeRollBackups = value; }
}
-
+
/// <summary>
/// Gets or sets the maximum size that the output file is allowed to reach
/// before being rolled over to backup files.
/// </summary>
/// <value>
- /// The maximum size in bytes that the output file is allowed to reach before being
+ /// The maximum size in bytes that the output file is allowed to reach before being
/// rolled over to backup files.
/// </value>
/// <remarks>
/// <para>
/// This property is equivalent to <see cref="MaximumFileSize"/> except
/// that it is required for differentiating the setter taking a
- /// <see cref="long"/> argument from the setter taking a <see cref="string"/>
+ /// <see cref="long"/> argument from the setter taking a <see cref="string"/>
/// argument.
/// </para>
/// <para>
@@ -381,20 +381,20 @@ namespace log4net.Appender
get { return m_maxFileSize; }
set { m_maxFileSize = value; }
}
-
+
/// <summary>
/// Gets or sets the maximum size that the output file is allowed to reach
/// before being rolled over to backup files.
/// </summary>
/// <value>
- /// The maximum size that the output file is allowed to reach before being
+ /// The maximum size that the output file is allowed to reach before being
/// rolled over to backup files.
/// </value>
/// <remarks>
/// <para>
/// This property allows you to specify the maximum size with the
- /// suffixes "KB", "MB" or "GB" so that the size is interpreted being
- /// expressed respectively in kilobytes, megabytes or gigabytes.
+ /// suffixes "KB", "MB" or "GB" so that the size is interpreted being
+ /// expressed respectively in kilobytes, megabytes or gigabytes.
/// </para>
/// <para>
/// For example, the value "10KB" will be interpreted as 10240 bytes.
@@ -415,7 +415,7 @@ namespace log4net.Appender
}
/// <summary>
- /// Gets or sets the rolling file count direction.
+ /// Gets or sets the rolling file count direction.
/// </summary>
/// <value>
/// The rolling file count direction.
@@ -432,7 +432,7 @@ namespace log4net.Appender
/// <para>
/// <see cref="CountDirection" /> >= 0 does the opposite i.e.
/// log.1 is the first backup made, log.5 is the 5th backup made, etc.
- /// For infinite backups use <see cref="CountDirection" /> >= 0 to reduce
+ /// For infinite backups use <see cref="CountDirection" /> >= 0 to reduce
/// rollover costs.
/// </para>
/// <para>The default file count direction is -1.</para>
@@ -442,7 +442,7 @@ namespace log4net.Appender
get { return m_countDirection; }
set { m_countDirection = value; }
}
-
+
/// <summary>
/// Gets or sets the rolling style.
/// </summary>
@@ -464,7 +464,7 @@ namespace log4net.Appender
set
{
m_rollingStyle = value;
- switch (m_rollingStyle)
+ switch (m_rollingStyle)
{
case RollingMode.Once:
m_rollDate = false;
@@ -486,7 +486,7 @@ namespace log4net.Appender
case RollingMode.Composite:
m_rollDate = true;
m_rollSize = true;
- break;
+ break;
}
}
}
@@ -526,7 +526,7 @@ namespace log4net.Appender
/// file.log.yyyy-mm-dd.curSizeRollBackup).
/// </para>
/// <para>
- /// This will make time based rollovers with a large number of backups
+ /// This will make time based rollovers with a large number of backups
/// much faster as the appender it won't have to rename all the backups!
/// </para>
/// </remarks>
@@ -551,8 +551,8 @@ namespace log4net.Appender
#endregion Private Static Fields
- #region Override implementation of FileAppender
-
+ #region Override implementation of FileAppender
+
/// <summary>
/// Sets the quiet writer being used.
/// </summary>
@@ -560,7 +560,7 @@ namespace log4net.Appender
/// This method can be overridden by sub classes.
/// </remarks>
/// <param name="writer">the writer to set</param>
- override protected void SetQWForFiles(TextWriter writer)
+ override protected void SetQWForFiles(TextWriter writer)
{
QuietWriter = new CountingQuietTextWriter(writer, ErrorHandler);
}
@@ -576,12 +576,12 @@ namespace log4net.Appender
/// is need and then appends to the file last.
/// </para>
/// </remarks>
- override protected void Append(LoggingEvent loggingEvent)
+ override protected void Append(LoggingEvent loggingEvent)
{
AdjustFileBeforeAppend();
base.Append(loggingEvent);
}
-
+
/// <summary>
/// Write out an array of logging events.
/// </summary>
@@ -593,7 +593,7 @@ namespace log4net.Appender
/// is need and then appends to the file last.
/// </para>
/// </remarks>
- override protected void Append(LoggingEvent[] loggingEvents)
+ override protected void Append(LoggingEvent[] loggingEvents)
{
AdjustFileBeforeAppend();
base.Append(loggingEvents);
@@ -671,7 +671,7 @@ namespace log4net.Appender
// Calculate the current size of the file
long currentCount = 0;
- if (append)
+ if (append)
{
using(SecurityContext.Impersonate(this))
{
@@ -696,7 +696,7 @@ namespace log4net.Appender
}
}
- if (!m_staticLogFileName)
+ if (!m_staticLogFileName)
{
m_scheduledFilename = fileName;
}
@@ -716,14 +716,14 @@ namespace log4net.Appender
/// <returns>the output file name</returns>
/// <remarks>
/// The output file name is based on the base fileName specified.
- /// If <see cref="StaticLogFileName"/> is set then the output
+ /// If <see cref="StaticLogFileName"/> is set then the output
/// file name is the same as the base file passed in. Otherwise
/// the output file depends on the date pattern, on the count
/// direction or both.
/// </remarks>
protected string GetNextOutputFileName(string fileName)
{
- if (!m_staticLogFileName)
+ if (!m_staticLogFileName)
{
fileName = fileName.Trim();
@@ -732,7 +732,7 @@ namespace log4net.Appender
fileName = CombinePath(fileName, m_now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo));
}
- if (m_countDirection >= 0)
+ if (m_countDirection >= 0)
{
fileName = CombinePath(fileName, "." + m_curSizeRollBackups);
}
@@ -751,7 +751,7 @@ namespace log4net.Appender
private void DetermineCurSizeRollBackups()
{
m_curSizeRollBackups = 0;
-
+
string fullPath = null;
string fileName = null;
@@ -807,10 +807,10 @@ namespace log4net.Appender
string baseFileName = Path.GetFileName(fullPath);
string[] files = Directory.GetFiles(directory, GetWildcardPatternForFile(baseFileName));
-
+
if (files != null)
{
- for (int i = 0; i < files.Length; i++)
+ for (int i = 0; i < files.Length; i++)
{
string curFileName = Path.GetFileName(files[i]);
if (curFileName.StartsWith(Path.GetFileNameWithoutExtension(baseFileName)))
@@ -830,9 +830,9 @@ namespace log4net.Appender
/// </summary>
private void RollOverIfDateBoundaryCrossing()
{
- if (m_staticLogFileName && m_rollDate)
+ if (m_staticLogFileName && m_rollDate)
{
- if (FileExists(m_baseFileName))
+ if (FileExists(m_baseFileName))
{
DateTime last;
using(SecurityContext.Impersonate(this)) {
@@ -851,7 +851,7 @@ namespace log4net.Appender
}
LogLog.Debug(declaringType, "["+last.ToString(m_datePattern,System.Globalization.DateTimeFormatInfo.InvariantInfo)+"] vs. ["+m_now.ToString(m_datePattern,System.Globalization.DateTimeFormatInfo.InvariantInfo)+"]");
- if (!(last.ToString(m_datePattern,System.Globalization.DateTimeFormatInfo.InvariantInfo).Equals(m_now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo))))
+ if (!(last.ToString(m_datePattern,System.Globalization.DateTimeFormatInfo.InvariantInfo).Equals(m_now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo))))
{
m_scheduledFilename = CombinePath(m_baseFileName, last.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo));
LogLog.Debug(declaringType, "Initial roll over to ["+m_scheduledFilename+"]");
@@ -875,7 +875,7 @@ namespace log4net.Appender
/// </list>
/// </para>
/// </remarks>
- protected void ExistingInit()
+ protected void ExistingInit()
{
DetermineCurSizeRollBackups();
RollOverIfDateBoundaryCrossing();
@@ -923,24 +923,24 @@ namespace log4net.Appender
// This is not a log file, so ignore
return;
}
- if (curFileName.Equals(baseFile))
+ if (curFileName.Equals(baseFile))
{
// Base log file is not an incremented logfile (.1 or .2, etc)
return;
}
-
+
/*
- if (m_staticLogFileName)
+ if (m_staticLogFileName)
{
int endLength = curFileName.Length - index;
- if (baseFile.Length + endLength != curFileName.Length)
+ if (baseFile.Length + endLength != curFileName.Length)
{
// file is probably scheduledFilename + .x so I don't care
return;
}
}
*/
-
+
// Only look for files in the current roll point
if (m_rollDate && !m_staticLogFileName)
{
@@ -953,12 +953,12 @@ namespace log4net.Appender
return;
}
}
-
- try
+
+ try
{
// Bump the counter up to the highest count seen so far
int backup = GetBackUpIndex(curFileName);
-
+
// caution: we might get a false positive when certain
// date patterns such as yyyyMMdd are used...those are
// valid number but aren't the kind of back up index
@@ -993,8 +993,8 @@ namespace log4net.Appender
}
LogLog.Debug(declaringType, "File name [" + curFileName + "] moves current count to [" + m_curSizeRollBackups + "]");
}
- }
- catch(FormatException)
+ }
+ catch(FormatException)
{
//this happens when file.log -> file.log.yyyy-MM-dd which is normal
//when staticLogFileName == false
@@ -1020,7 +1020,7 @@ namespace log4net.Appender
{
fileName = Path.GetFileNameWithoutExtension(fileName);
}
-
+
int index = fileName.LastIndexOf(".");
if (index > 0)
{
@@ -1033,7 +1033,7 @@ namespace log4net.Appender
}
/// <summary>
- /// Takes a list of files and a base file name, and looks for
+ /// Takes a list of files and a base file name, and looks for
/// 'incremented' versions of the base file. Bumps the max
/// count up to the highest count seen.
/// </summary>
@@ -1061,13 +1061,13 @@ namespace log4net.Appender
/// Essentially the date pattern is examined to determine what the
/// most suitable roll point is. The roll point chosen is the roll point
/// with the smallest period that can be detected using the date pattern
- /// supplied. i.e. if the date pattern only outputs the year, month, day
+ /// supplied. i.e. if the date pattern only outputs the year, month, day
/// and hour then the smallest roll point that can be detected would be
/// and hourly roll point as minutes could not be detected.
/// </remarks>
- private RollPoint ComputeCheckPeriod(string datePattern)
+ private RollPoint ComputeCheckPeriod(string datePattern)
{
- // s_date1970 is 1970-01-01 00:00:00 this is UniversalSortableDateTimePattern
+ // s_date1970 is 1970-01-01 00:00:00 this is UniversalSortableDateTimePattern
// (based on ISO 8601) using universal time. This date is used for reference
// purposes to calculate the resolution of the date pattern.
@@ -1075,7 +1075,7 @@ namespace log4net.Appender
string r0 = s_date1970.ToString(datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo);
// Check each type of rolling mode starting with the smallest increment.
- for(int i = (int)RollPoint.TopOfMinute; i <= (int)RollPoint.TopOfMonth; i++)
+ for(int i = (int)RollPoint.TopOfMinute; i <= (int)RollPoint.TopOfMonth; i++)
{
// Get string representation of next pattern
string r1 = NextCheckDate(s_date1970, (RollPoint)i).ToString(datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo);
@@ -1083,7 +1083,7 @@ namespace log4net.Appender
LogLog.Debug(declaringType, "Type = ["+i+"], r0 = ["+r0+"], r1 = ["+r1+"]");
// Check if the string representations are different
- if (r0 != null && r1 != null && !r0.Equals(r1))
+ if (r0 != null && r1 != null && !r0.Equals(r1))
{
// Found highest precision roll point
return (RollPoint)i;
@@ -1099,13 +1099,13 @@ namespace log4net.Appender
/// <remarks>
/// <para>
/// This is part of the <see cref="IOptionHandler"/> delayed object
- /// activation scheme. The <see cref="ActivateOptions"/> method must
+ /// activation scheme. The <see cref="ActivateOptions"/> method must
/// be called on this object after the configuration properties have
/// been set. Until <see cref="ActivateOptions"/> is called this
- /// object is in an undefined state and must not be used.
+ /// object is in an undefined state and must not be used.
/// </para>
/// <para>
- /// If any of the configuration properties are modified then
+ /// If any of the configuration properties are modified then
/// <see cref="ActivateOptions"/> must be called again.
/// </para>
/// <para>
@@ -1114,14 +1114,14 @@ namespace log4net.Appender
/// the current number of backups.
/// </para>
/// </remarks>
- override public void ActivateOptions()
+ override public void ActivateOptions()
{
if (m_dateTime == null)
{
m_dateTime = new LocalDateTime();
}
- if (m_rollDate && m_datePattern != null)
+ if (m_rollDate && m_datePattern != null)
{
m_now = m_dateTime.Now;
m_rollPoint = ComputeCheckPeriod(m_datePattern);
@@ -1133,8 +1133,8 @@ namespace log4net.Appender
// next line added as this removes the name check in rollOver
m_nextCheck = NextCheckDate(m_now, m_rollPoint);
- }
- else
+ }
+ else
{
if (m_rollDate)
{
@@ -1169,16 +1169,16 @@ namespace log4net.Appender
}
ExistingInit();
-
+
base.ActivateOptions();
}
#endregion
-
+
#region Roll File
/// <summary>
- ///
+ ///
/// </summary>
/// <param name="path1"></param>
/// <param name="path2">.1, .2, .3, etc.</param>
@@ -1203,51 +1203,51 @@ namespace log4net.Appender
/// <remarks>
/// <para>
/// Rollover the file(s) to date/time tagged file(s).
- /// Resets curSizeRollBackups.
+ /// Resets curSizeRollBackups.
/// If fileIsOpen is set then the new file is opened (through SafeOpenFile).
/// </para>
/// </remarks>
- protected void RollOverTime(bool fileIsOpen)
+ protected void RollOverTime(bool fileIsOpen)
{
- if (m_staticLogFileName)
+ if (m_staticLogFileName)
{
// Compute filename, but only if datePattern is specified
- if (m_datePattern == null)
+ if (m_datePattern == null)
{
ErrorHandler.Error("Missing DatePattern option in rollOver().");
return;
}
-
+
//is the new file name equivalent to the 'current' one
//something has gone wrong if we hit this -- we should only
//roll over if the new file will be different from the old
string dateFormat = m_now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo);
- if (m_scheduledFilename.Equals(CombinePath(File, dateFormat)))
+ if (m_scheduledFilename.Equals(CombinePath(File, dateFormat)))
{
ErrorHandler.Error("Compare " + m_scheduledFilename + " : " + CombinePath(File, dateFormat));
return;
}
-
+
if (fileIsOpen)
{
// close current file, and rename it to datedFilename
this.CloseFile();
}
-
+
//we may have to roll over a large number of backups here
- for (int i = 1; i <= m_curSizeRollBackups; i++)
+ for (int i = 1; i <= m_curSizeRollBackups; i++)
{
string from = CombinePath(File, "." + i);
string to = CombinePath(m_scheduledFilename, "." + i);
RollFile(from, to);
}
-
+
RollFile(File, m_scheduledFilename);
}
-
+
//We've cleared out the old date and are ready for the new
- m_curSizeRollBackups = 0;
-
+ m_curSizeRollBackups = 0;
+
//new scheduled name
m_scheduledFilename = CombinePath(File, m_now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo));
@@ -1257,7 +1257,7 @@ namespace log4net.Appender
SafeOpenFile(m_baseFileName, false);
}
}
-
+
/// <summary>
/// Renames file <paramref name="fromFile"/> to file <paramref name="toFile"/>.
/// </summary>
@@ -1269,7 +1269,7 @@ namespace log4net.Appender
/// also checks for existence of target file and deletes if it does.
/// </para>
/// </remarks>
- protected void RollFile(string fromFile, string toFile)
+ protected void RollFile(string fromFile, string toFile)
{
if (FileExists(fromFile))
{
@@ -1313,7 +1313,7 @@ namespace log4net.Appender
return System.IO.File.Exists(path);
}
}
-
+
/// <summary>
/// Deletes the specified file if it exists.
/// </summary>
@@ -1326,9 +1326,9 @@ namespace log4net.Appender
/// be deleted, but it still can be moved.
/// </para>
/// </remarks>
- protected void DeleteFile(string fileName)
+ protected void DeleteFile(string fileName)
{
- if (FileExists(fileName))
+ if (FileExists(fileName))
{
// We may not have permission to delete the file, or the file may be locked
@@ -1375,7 +1375,7 @@ namespace log4net.Appender
}
}
}
-
+
/// <summary>
/// Implements file roll base on file size.
/// </summary>
@@ -1402,18 +1402,18 @@ namespace log4net.Appender
/// renamed if needed and no files are deleted.
/// </para>
/// </remarks>
- protected void RollOverSize()
+ protected void RollOverSize()
{
this.CloseFile(); // keep windows happy.
-
+
LogLog.Debug(declaringType, "rolling over count ["+((CountingQuietTextWriter)QuietWriter).Count+"]");
LogLog.Debug(declaringType, "maxSizeRollBackups ["+m_maxSizeRollBackups+"]");
LogLog.Debug(declaringType, "curSizeRollBackups ["+m_curSizeRollBackups+"]");
LogLog.Debug(declaringType, "countDirection ["+m_countDirection+"]");
RollOverRenameFiles(File);
-
- if (!m_staticLogFileName && m_countDirection >= 0)
+
+ if (!m_staticLogFileName && m_countDirection >= 0)
{
m_curSizeRollBackups++;
}
@@ -1434,7 +1434,7 @@ namespace log4net.Appender
/// If <c>countDirection</c> < 0, then files
/// {<c>File.1</c>, ..., <c>File.curSizeRollBackups -1</c>}
/// are renamed to {<c>File.2</c>, ...,
- /// <c>File.curSizeRollBackups</c>}.
+ /// <c>File.curSizeRollBackups</c>}.
/// </para>
/// <para>
/// If <c>maxSizeRollBackups</c> is equal to zero, then the
@@ -1448,35 +1448,35 @@ namespace log4net.Appender
/// This is called by <see cref="RollOverSize"/> to rename the files.
/// </para>
/// </remarks>
- protected void RollOverRenameFiles(string baseFileName)
+ protected void RollOverRenameFiles(string baseFileName)
{
// If maxBackups <= 0, then there is no file renaming to be done.
- if (m_maxSizeRollBackups != 0)
+ if (m_maxSizeRollBackups != 0)
{
- if (m_countDirection < 0)
+ if (m_countDirection < 0)
{
// Delete the oldest file, to keep Windows happy.
- if (m_curSizeRollBackups == m_maxSizeRollBackups)
+ if (m_curSizeRollBackups == m_maxSizeRollBackups)
{
DeleteFile(CombinePath(baseFileName, "." + m_maxSizeRollBackups));
m_curSizeRollBackups--;
}
-
+
// Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
- for (int i = m_curSizeRollBackups; i >= 1; i--)
+ for (int i = m_curSizeRollBackups; i >= 1; i--)
{
RollFile((CombinePath(baseFileName, "." + i)), (CombinePath(baseFileName, "." + (i + 1))));
}
-
+
m_curSizeRollBackups++;
// Rename fileName to fileName.1
RollFile(baseFileName, CombinePath(baseFileName, ".1"));
- }
- else
+ }
+ else
{
//countDirection >= 0
- if (m_curSizeRollBackups >= m_maxSizeRollBackups && m_maxSizeRollBackups > 0)
+ if (m_curSizeRollBackups >= m_maxSizeRollBackups && m_maxSizeRollBackups > 0)
{
//delete the first and keep counting up.
int oldestFileIndex = m_curSizeRollBackups - m_maxSizeRollBackups;
@@ -1506,7 +1506,7 @@ namespace log4net.Appender
else
{
int lastDotIndex = archiveFileBaseName.LastIndexOf(".");
- if (lastDotIndex >= 0)
+ if (lastDotIndex >= 0)
{
archiveFileBaseName = archiveFileBaseName.Substring(0, lastDotIndex);
}
@@ -1516,8 +1516,8 @@ namespace log4net.Appender
// Delete the archive file
DeleteFile(CombinePath(archiveFileBaseName, "." + oldestFileIndex));
}
-
- if (m_staticLogFileName)
+
+ if (m_staticLogFileName)
{
m_curSizeRollBackups++;
RollFile(baseFileName, CombinePath(baseFileName, "." + m_curSizeRollBackups));
@@ -1547,13 +1547,13 @@ namespace log4net.Appender
/// worth of time and get the start time of the next window for the rollpoint.
/// </para>
/// </remarks>
- protected DateTime NextCheckDate(DateTime currentDateTime, RollPoint rollPoint)
+ protected DateTime NextCheckDate(DateTime currentDateTime, RollPoint rollPoint)
{
// Local variable to work on (this does not look very efficient)
DateTime current = currentDateTime;
// Do slightly different things depending on what the type of roll point we want.
- switch(rollPoint)
+ switch(rollPoint)
{
case RollPoint.TopOfMinute:
current = current.AddMilliseconds(-current.Millisecond);
@@ -1573,11 +1573,11 @@ namespace log4net.Appender
current = current.AddSeconds(-current.Second);
current = current.AddMinutes(-current.Minute);
- if (current.Hour < 12)
+ if (current.Hour < 12)
{
current = current.AddHours(12 - current.Hour);
- }
- else
+ }
+ else
{
current = current.AddHours(-current.Hour);
current = current.AddDays(1);
@@ -1608,7 +1608,7 @@ namespace log4net.Appender
current = current.AddDays(1 - current.Day); /* first day of month is 1 not 0 */
current = current.AddMonths(1);
break;
- }
+ }
return current;
}
@@ -1624,38 +1624,38 @@ namespace log4net.Appender
private IDateTime m_dateTime = null;
/// <summary>
- /// The date pattern. By default, the pattern is set to <c>".yyyy-MM-dd"</c>
+ /// The date pattern. By default, the pattern is set to <c>".yyyy-MM-dd"</c>
/// meaning daily rollover.
/// </summary>
private string m_datePattern = ".yyyy-MM-dd";
-
+
/// <summary>
/// The actual formatted filename that is currently being written to
/// or will be the file transferred to on roll over
/// (based on staticLogFileName).
/// </summary>
private string m_scheduledFilename = null;
-
+
/// <summary>
/// The timestamp when we shall next recompute the filename.
/// </summary>
private DateTime m_nextCheck = DateTime.MaxValue;
-
+
/// <summary>
/// Holds date of last roll over
/// </summary>
private DateTime m_now;
-
+
/// <summary>
/// The type of rolling done
/// </summary>
private RollPoint m_rollPoint;
-
+
/// <summary>
/// The default maximum file size is 10MB
/// </summary>
private long m_maxFileSize = 10*1024*1024;
-
+
/// <summary>
/// There is zero backup files by default
/// </summary>
@@ -1665,12 +1665,12 @@ namespace log4net.Appender
/// How many sized based backups have been made so far
/// </summary>
private int m_curSizeRollBackups = 0;
-
+
/// <summary>
- /// The rolling file count direction.
+ /// The rolling file count direction.
/// </summary>
private int m_countDirection = -1;
-
+
/// <summary>
/// The rolling mode used in this appender.
/// </summary>
@@ -1685,12 +1685,12 @@ namespace log4net.Appender
/// Cache flag set if we are rolling by size.
/// </summary>
private bool m_rollSize = true;
-
+
/// <summary>
/// Value indicating whether to always log to the same file.
/// </summary>
private bool m_staticLogFileName = true;
-
+
/// <summary>
/// Value indicating whether to preserve the file name extension when rolling.
/// </summary>
[5/7] logging-log4net git commit: Refactor: fixed spaces to be tabs
in RollingFileAppender.cs
Posted by dp...@apache.org.
Refactor: fixed spaces to be tabs in RollingFileAppender.cs
Project: http://git-wip-us.apache.org/repos/asf/logging-log4net/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4net/commit/89d3820b
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4net/tree/89d3820b
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4net/diff/89d3820b
Branch: refs/heads/develop
Commit: 89d3820b17cb6287c0a1da4ce236a6c2eba741a3
Parents: c8e5130
Author: Dominik Psenner <dp...@apache.org>
Authored: Thu Jul 27 17:38:34 2017 +0200
Committer: Dominik Psenner <dp...@apache.org>
Committed: Thu Jul 27 17:38:34 2017 +0200
----------------------------------------------------------------------
src/Appender/RollingFileAppender.cs | 330 +++++++++++++++----------------
1 file changed, 165 insertions(+), 165 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/89d3820b/src/Appender/RollingFileAppender.cs
----------------------------------------------------------------------
diff --git a/src/Appender/RollingFileAppender.cs b/src/Appender/RollingFileAppender.cs
index a56766b..fcdd13a 100644
--- a/src/Appender/RollingFileAppender.cs
+++ b/src/Appender/RollingFileAppender.cs
@@ -124,10 +124,10 @@ namespace log4net.Appender
/// <author>Douglas de la Torre</author>
/// <author>Edward Smit</author>
public class RollingFileAppender : FileAppender
- {
- #region Public Enums
+ {
+ #region Public Enums
- /// <summary>
+ /// <summary>
/// Style of rolling to use
/// </summary>
/// <remarks>
@@ -259,7 +259,7 @@ namespace log4net.Appender
#region Public Instance Properties
#if !NET_1_0 && !CLI_1_0 && !NETCF
- /// <summary>
+ /// <summary>
/// Gets or sets the strategy for determining the current date and time. The default
/// implementation is to use LocalDateTime which internally calls through to DateTime.Now.
/// DateTime.UtcNow may be used on frameworks newer than .NET 1.0 by specifying
@@ -272,17 +272,17 @@ namespace log4net.Appender
/// <para>
/// Gets or sets the <see cref="RollingFileAppender.IDateTime"/> used to return the current date and time.
/// </para>
- /// <para>
- /// There are two built strategies for determining the current date and time,
+ /// <para>
+ /// There are two built strategies for determining the current date and time,
/// <see cref="RollingFileAppender.LocalDateTime"/>
- /// and <see cref="RollingFileAppender.UniversalDateTime"/>.
- /// </para>
- /// <para>
+ /// and <see cref="RollingFileAppender.UniversalDateTime"/>.
+ /// </para>
+ /// <para>
/// The default strategy is <see cref="RollingFileAppender.LocalDateTime"/>.
/// </para>
/// </remarks>
#else
- /// <summary>
+ /// <summary>
/// Gets or sets the strategy for determining the current date and time. The default
/// implementation is to use LocalDateTime which internally calls through to DateTime.Now.
/// </summary>
@@ -293,12 +293,12 @@ namespace log4net.Appender
/// <para>
/// Gets or sets the <see cref="RollingFileAppender.IDateTime"/> used to return the current date and time.
/// </para>
- /// <para>
+ /// <para>
/// The default strategy is <see cref="RollingFileAppender.LocalDateTime"/>.
/// </para>
/// </remarks>
#endif
- public IDateTime DateTimeStrategy
+ public IDateTime DateTimeStrategy
{
get { return m_dateTime; }
set { m_dateTime = value; }
@@ -491,25 +491,25 @@ namespace log4net.Appender
}
}
- /// <summary>
- /// Gets or sets a value indicating whether to preserve the file name extension when rolling.
- /// </summary>
- /// <value>
- /// <c>true</c> if the file name extension should be preserved.
- /// </value>
- /// <remarks>
- /// <para>
- /// By default file.log is rolled to file.log.yyyy-MM-dd or file.log.curSizeRollBackup.
- /// However, under Windows the new file name will loose any program associations as the
- /// extension is changed. Optionally file.log can be renamed to file.yyyy-MM-dd.log or
- /// file.curSizeRollBackup.log to maintain any program associations.
- /// </para>
- /// </remarks>
- public bool PreserveLogFileNameExtension
- {
- get { return m_preserveLogFileNameExtension; }
- set { m_preserveLogFileNameExtension = value; }
- }
+ /// <summary>
+ /// Gets or sets a value indicating whether to preserve the file name extension when rolling.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if the file name extension should be preserved.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// By default file.log is rolled to file.log.yyyy-MM-dd or file.log.curSizeRollBackup.
+ /// However, under Windows the new file name will loose any program associations as the
+ /// extension is changed. Optionally file.log can be renamed to file.yyyy-MM-dd.log or
+ /// file.curSizeRollBackup.log to maintain any program associations.
+ /// </para>
+ /// </remarks>
+ public bool PreserveLogFileNameExtension
+ {
+ get { return m_preserveLogFileNameExtension; }
+ set { m_preserveLogFileNameExtension = value; }
+ }
/// <summary>
/// Gets or sets a value indicating whether to always log to
@@ -538,18 +538,18 @@ namespace log4net.Appender
#endregion Public Instance Properties
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the RollingFileAppender class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private readonly static Type declaringType = typeof(RollingFileAppender);
+ /// <summary>
+ /// The fully qualified type of the RollingFileAppender class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private readonly static Type declaringType = typeof(RollingFileAppender);
- #endregion Private Static Fields
+ #endregion Private Static Fields
#region Override implementation of FileAppender
@@ -582,7 +582,7 @@ namespace log4net.Appender
base.Append(loggingEvent);
}
- /// <summary>
+ /// <summary>
/// Write out an array of logging events.
/// </summary>
/// <param name="loggingEvents">the events to write to file.</param>
@@ -729,12 +729,12 @@ namespace log4net.Appender
if (m_rollDate)
{
- fileName = CombinePath(fileName, m_now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo));
+ fileName = CombinePath(fileName, m_now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo));
}
if (m_countDirection >= 0)
{
- fileName = CombinePath(fileName, "." + m_curSizeRollBackups);
+ fileName = CombinePath(fileName, "." + m_curSizeRollBackups);
}
}
@@ -775,14 +775,14 @@ namespace log4net.Appender
/// <returns></returns>
private string GetWildcardPatternForFile(string baseFileName)
{
- if (m_preserveLogFileNameExtension)
- {
- return Path.GetFileNameWithoutExtension(baseFileName) + "*" + Path.GetExtension(baseFileName);
- }
- else
- {
- return baseFileName + '*';
- }
+ if (m_preserveLogFileNameExtension)
+ {
+ return Path.GetFileNameWithoutExtension(baseFileName) + "*" + Path.GetExtension(baseFileName);
+ }
+ else
+ {
+ return baseFileName + '*';
+ }
}
/// <summary>
@@ -837,7 +837,7 @@ namespace log4net.Appender
DateTime last;
using(SecurityContext.Impersonate(this)) {
#if !NET_1_0 && !CLI_1_0 && !NETCF
- if (DateTimeStrategy is UniversalDateTime)
+ if (DateTimeStrategy is UniversalDateTime)
{
last = System.IO.File.GetLastWriteTimeUtc(m_baseFileName);
}
@@ -846,9 +846,9 @@ namespace log4net.Appender
#endif
last = System.IO.File.GetLastWriteTime(m_baseFileName);
#if !NET_1_0 && !CLI_1_0 && !NETCF
- }
+ }
#endif
- }
+ }
LogLog.Debug(declaringType, "["+last.ToString(m_datePattern,System.Globalization.DateTimeFormatInfo.InvariantInfo)+"] vs. ["+m_now.ToString(m_datePattern,System.Globalization.DateTimeFormatInfo.InvariantInfo)+"]");
if (!(last.ToString(m_datePattern,System.Globalization.DateTimeFormatInfo.InvariantInfo).Equals(m_now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo))))
@@ -918,7 +918,7 @@ namespace log4net.Appender
/// <param name="curFileName"></param>
private void InitializeFromOneFile(string baseFile, string curFileName)
{
- if (curFileName.StartsWith(Path.GetFileNameWithoutExtension(baseFile)) == false)
+ if (curFileName.StartsWith(Path.GetFileNameWithoutExtension(baseFile)) == false)
{
// This is not a log file, so ignore
return;
@@ -929,7 +929,7 @@ namespace log4net.Appender
return;
}
- /*
+ /*
if (m_staticLogFileName)
{
int endLength = curFileName.Length - index;
@@ -939,7 +939,7 @@ namespace log4net.Appender
return;
}
}
- */
+ */
// Only look for files in the current roll point
if (m_rollDate && !m_staticLogFileName)
@@ -957,42 +957,42 @@ namespace log4net.Appender
try
{
// Bump the counter up to the highest count seen so far
- int backup = GetBackUpIndex(curFileName);
-
- // caution: we might get a false positive when certain
- // date patterns such as yyyyMMdd are used...those are
- // valid number but aren't the kind of back up index
- // we're looking for
- if (backup > m_curSizeRollBackups)
- {
- if (0 == m_maxSizeRollBackups)
- {
- // Stay at zero when zero backups are desired
- }
- else if (-1 == m_maxSizeRollBackups)
- {
- // Infinite backups, so go as high as the highest value
- m_curSizeRollBackups = backup;
- }
- else
- {
- // Backups limited to a finite number
- if (m_countDirection >= 0)
- {
- // Go with the highest file when counting up
- m_curSizeRollBackups = backup;
- }
- else
- {
- // Clip to the limit when counting down
- if (backup <= m_maxSizeRollBackups)
- {
- m_curSizeRollBackups = backup;
- }
- }
- }
- LogLog.Debug(declaringType, "File name [" + curFileName + "] moves current count to [" + m_curSizeRollBackups + "]");
- }
+ int backup = GetBackUpIndex(curFileName);
+
+ // caution: we might get a false positive when certain
+ // date patterns such as yyyyMMdd are used...those are
+ // valid number but aren't the kind of back up index
+ // we're looking for
+ if (backup > m_curSizeRollBackups)
+ {
+ if (0 == m_maxSizeRollBackups)
+ {
+ // Stay at zero when zero backups are desired
+ }
+ else if (-1 == m_maxSizeRollBackups)
+ {
+ // Infinite backups, so go as high as the highest value
+ m_curSizeRollBackups = backup;
+ }
+ else
+ {
+ // Backups limited to a finite number
+ if (m_countDirection >= 0)
+ {
+ // Go with the highest file when counting up
+ m_curSizeRollBackups = backup;
+ }
+ else
+ {
+ // Clip to the limit when counting down
+ if (backup <= m_maxSizeRollBackups)
+ {
+ m_curSizeRollBackups = backup;
+ }
+ }
+ }
+ LogLog.Debug(declaringType, "File name [" + curFileName + "] moves current count to [" + m_curSizeRollBackups + "]");
+ }
}
catch(FormatException)
{
@@ -1002,37 +1002,37 @@ namespace log4net.Appender
}
}
- /// <summary>
- /// Attempts to extract a number from the end of the file name that indicates
- /// the number of the times the file has been rolled over.
- /// </summary>
- /// <remarks>
- /// Certain date pattern extensions like yyyyMMdd will be parsed as valid backup indexes.
- /// </remarks>
- /// <param name="curFileName"></param>
- /// <returns></returns>
- private int GetBackUpIndex(string curFileName)
- {
- int backUpIndex = -1;
- string fileName = curFileName;
-
- if (m_preserveLogFileNameExtension)
- {
- 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
- SystemInfo.TryParse(fileName.Substring(index + 1), out backUpIndex);
- }
-
- return backUpIndex;
- }
-
- /// <summary>
+ /// <summary>
+ /// Attempts to extract a number from the end of the file name that indicates
+ /// the number of the times the file has been rolled over.
+ /// </summary>
+ /// <remarks>
+ /// Certain date pattern extensions like yyyyMMdd will be parsed as valid backup indexes.
+ /// </remarks>
+ /// <param name="curFileName"></param>
+ /// <returns></returns>
+ private int GetBackUpIndex(string curFileName)
+ {
+ int backUpIndex = -1;
+ string fileName = curFileName;
+
+ if (m_preserveLogFileNameExtension)
+ {
+ 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
+ SystemInfo.TryParse(fileName.Substring(index + 1), out backUpIndex);
+ }
+
+ return backUpIndex;
+ }
+
+ /// <summary>
/// Takes a list of files and a base file name, and looks for
/// 'incremented' versions of the base file. Bumps the max
/// count up to the highest count seen.
@@ -1165,7 +1165,7 @@ namespace log4net.Appender
if (m_rollDate && File != null && m_scheduledFilename == null)
{
- m_scheduledFilename = CombinePath(File, m_now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo));
+ m_scheduledFilename = CombinePath(File, m_now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo));
}
ExistingInit();
@@ -1177,24 +1177,24 @@ namespace log4net.Appender
#region Roll File
- /// <summary>
- ///
- /// </summary>
- /// <param name="path1"></param>
- /// <param name="path2">.1, .2, .3, etc.</param>
- /// <returns></returns>
- private string CombinePath(string path1, string path2)
- {
- string extension = Path.GetExtension(path1);
- if (m_preserveLogFileNameExtension && extension.Length > 0)
- {
- return Path.Combine(Path.GetDirectoryName(path1), Path.GetFileNameWithoutExtension(path1) + path2 + extension);
- }
- else
- {
- return path1 + path2;
- }
- }
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="path1"></param>
+ /// <param name="path2">.1, .2, .3, etc.</param>
+ /// <returns></returns>
+ private string CombinePath(string path1, string path2)
+ {
+ string extension = Path.GetExtension(path1);
+ if (m_preserveLogFileNameExtension && extension.Length > 0)
+ {
+ return Path.Combine(Path.GetDirectoryName(path1), Path.GetFileNameWithoutExtension(path1) + path2 + extension);
+ }
+ else
+ {
+ return path1 + path2;
+ }
+ }
/// <summary>
/// Rollover the file(s) to date/time tagged file(s).
@@ -1222,9 +1222,9 @@ namespace log4net.Appender
//something has gone wrong if we hit this -- we should only
//roll over if the new file will be different from the old
string dateFormat = m_now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo);
- if (m_scheduledFilename.Equals(CombinePath(File, dateFormat)))
+ if (m_scheduledFilename.Equals(CombinePath(File, dateFormat)))
{
- ErrorHandler.Error("Compare " + m_scheduledFilename + " : " + CombinePath(File, dateFormat));
+ ErrorHandler.Error("Compare " + m_scheduledFilename + " : " + CombinePath(File, dateFormat));
return;
}
@@ -1237,8 +1237,8 @@ namespace log4net.Appender
//we may have to roll over a large number of backups here
for (int i = 1; i <= m_curSizeRollBackups; i++)
{
- string from = CombinePath(File, "." + i);
- string to = CombinePath(m_scheduledFilename, "." + i);
+ string from = CombinePath(File, "." + i);
+ string to = CombinePath(m_scheduledFilename, "." + i);
RollFile(from, to);
}
@@ -1249,7 +1249,7 @@ namespace log4net.Appender
m_curSizeRollBackups = 0;
//new scheduled name
- m_scheduledFilename = CombinePath(File, m_now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo));
+ m_scheduledFilename = CombinePath(File, m_now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo));
if (fileIsOpen)
{
@@ -1458,20 +1458,20 @@ namespace log4net.Appender
// Delete the oldest file, to keep Windows happy.
if (m_curSizeRollBackups == m_maxSizeRollBackups)
{
- DeleteFile(CombinePath(baseFileName, "." + m_maxSizeRollBackups));
+ DeleteFile(CombinePath(baseFileName, "." + m_maxSizeRollBackups));
m_curSizeRollBackups--;
}
// Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
for (int i = m_curSizeRollBackups; i >= 1; i--)
{
- RollFile((CombinePath(baseFileName, "." + i)), (CombinePath(baseFileName, "." + (i + 1))));
+ RollFile((CombinePath(baseFileName, "." + i)), (CombinePath(baseFileName, "." + (i + 1))));
}
m_curSizeRollBackups++;
// Rename fileName to fileName.1
- RollFile(baseFileName, CombinePath(baseFileName, ".1"));
+ RollFile(baseFileName, CombinePath(baseFileName, ".1"));
}
else
{
@@ -1493,34 +1493,34 @@ namespace log4net.Appender
string archiveFileBaseName = baseFileName;
if (!m_staticLogFileName)
{
- if (m_preserveLogFileNameExtension)
- {
- string extension = Path.GetExtension(archiveFileBaseName);
- string baseName = Path.GetFileNameWithoutExtension(archiveFileBaseName);
+ 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
- {
+ }
+ else
+ {
int lastDotIndex = archiveFileBaseName.LastIndexOf(".");
if (lastDotIndex >= 0)
{
archiveFileBaseName = archiveFileBaseName.Substring(0, lastDotIndex);
}
- }
+ }
}
// Delete the archive file
- DeleteFile(CombinePath(archiveFileBaseName, "." + oldestFileIndex));
+ DeleteFile(CombinePath(archiveFileBaseName, "." + oldestFileIndex));
}
if (m_staticLogFileName)
{
m_curSizeRollBackups++;
- RollFile(baseFileName, CombinePath(baseFileName, "." + m_curSizeRollBackups));
+ RollFile(baseFileName, CombinePath(baseFileName, "." + m_curSizeRollBackups));
}
}
}
@@ -1691,7 +1691,7 @@ namespace log4net.Appender
/// </summary>
private bool m_staticLogFileName = true;
- /// <summary>
+ /// <summary>
/// Value indicating whether to preserve the file name extension when rolling.
/// </summary>
private bool m_preserveLogFileNameExtension = false;
@@ -1765,7 +1765,7 @@ namespace log4net.Appender
}
#if !NET_1_0 && !CLI_1_0 && !NETCF
- /// <summary>
+ /// <summary>
/// Implementation of <see cref="IDateTime"/> that returns the current time as the coordinated universal time (UTC).
/// </summary>
private class UniversalDateTime : IDateTime
@@ -1786,6 +1786,6 @@ namespace log4net.Appender
}
#endif
- #endregion DateTime
+ #endregion DateTime
}
}