diff --git a/src/Orchard/Logging/OrchardFileAppender.cs b/src/Orchard/Logging/OrchardFileAppender.cs index 08a8fae6f..1af9d2d79 100644 --- a/src/Orchard/Logging/OrchardFileAppender.cs +++ b/src/Orchard/Logging/OrchardFileAppender.cs @@ -9,8 +9,16 @@ namespace Orchard.Logging { /// private static readonly Dictionary _suffixes = new Dictionary(); + /// + /// The number of suffix attempts that will be made on each OpenFile method call. + /// private const int Retries = 50; + /// + /// Maximum number of suffixes recorded before a cleanup happens to recycle memory. + /// + private const int MaxSuffixes = 100; + /// /// Opens the log file adding an incremental suffix to the filename if required due to an openning failure (usually, locking). /// @@ -22,6 +30,10 @@ namespace Orchard.Logging { string completeFilename = GetNextOutputFileName(fileName); string currentFilename = fileName; + if (_suffixes.Count > MaxSuffixes) { + _suffixes.Clear(); + } + if (!_suffixes.ContainsKey(completeFilename)) { _suffixes[completeFilename] = 0; } @@ -48,6 +60,11 @@ namespace Orchard.Logging { } } + /// + /// Calls the base class OpenFile method. Allows this method to be mocked. + /// + /// The filename as specified in the configuration file. + /// Boolean flag indicating weather the log file should be appended if it already exists. protected virtual void BaseOpenFile(string fileName, bool append) { base.OpenFile(fileName, append); }