diff U3B D:\mes documents\Visual Studio Projects\log4net-cvs\RollingFileAppender.cs D:\mes documents\Visual Studio Projects\log4net-cvs\logging-log4net\src\Appender\RollingFileAppender.cs --- D:\mes documents\Visual Studio Projects\log4net-cvs\RollingFileAppender.cs Mon Apr 25 15:19:07 2005 +++ D:\mes documents\Visual Studio Projects\log4net-cvs\logging-log4net\src\Appender\RollingFileAppender.cs Mon Apr 25 15:10:04 2005 @@ -112,11 +112,6 @@ /// file to be deleted is moved to a temporary name before being deleted. /// /// - /// - /// - /// A maximum number of backup files when rolling on date/time boundaries is not supported. - /// - /// /// /// Nicko Cadell /// Gert Driesen @@ -549,6 +544,42 @@ } } + if (m_rollDate && m_maxSizeRollBackups != 0) + { + FileInfo fi = new FileInfo(File); + DateTime currentDate = m_now; + string shortFileName = fi.Name; + string dirName = fi.DirectoryName + Path.DirectorySeparatorChar; + + // Build all valid file names + string[] validFilesName = new string[m_maxSizeRollBackups]; + validFilesName[0] = fileName.Substring( dirName.Length ); + for(int i=1; i /// Roll on to the next interval after the date passed @@ -1347,6 +1378,83 @@ current = current.AddMonths(1); break; } + return current; + } + + /// + /// Roll on to the previous interval before the date passed + /// + /// the current date + /// the type of roll point we are working with + /// the previous roll point an interval before the currentDateTime date + /// + /// Advances the date to the previous roll point before the + /// currentDateTime date passed to the method. + /// + protected DateTime PreviousCheckDate(DateTime currentDateTime, RollPoint rollPoint) + { + // Local variable to work on (this does not look very efficient) + DateTime current = currentDateTime; + + // Do different things depending on what the type of roll point we are going for is + switch(rollPoint) + { + case RollPoint.TopOfMinute: + current = current.AddMilliseconds(-current.Millisecond); + current = current.AddSeconds(-current.Second); + current = current.AddMinutes(-1); + break; + + case RollPoint.TopOfHour: + current = current.AddMilliseconds(-current.Millisecond); + current = current.AddSeconds(-current.Second); + current = current.AddMinutes(-current.Minute); + current = current.AddHours(-1); + break; + + case RollPoint.HalfDay: + current = current.AddMilliseconds(-current.Millisecond); + current = current.AddSeconds(-current.Second); + current = current.AddMinutes(-current.Minute); + + if (current.Hour < 12) + { + current = current.AddHours( -current.Hour - 12 ); + } + else + { + current = current.AddHours( -current.Hour ); + } + break; + + case RollPoint.TopOfDay: + current = current.AddMilliseconds(-current.Millisecond); + current = current.AddSeconds(-current.Second); + current = current.AddMinutes(-current.Minute); + current = current.AddHours(-current.Hour); + current = current.AddDays(-1); + break; + + case RollPoint.TopOfWeek: + current = current.AddMilliseconds(-current.Millisecond); + current = current.AddSeconds(-current.Second); + current = current.AddMinutes(-current.Minute); + current = current.AddHours(-current.Hour); + current = current.AddDays( -(int)current.DayOfWeek - 7); + break; + + case RollPoint.TopOfMonth: + current = current.AddMilliseconds(-current.Millisecond); + current = current.AddSeconds(-current.Second); + current = current.AddMinutes(-current.Minute); + current = current.AddHours(-current.Hour); + current = current.AddDays( -current.Day ); + // To be in previous month + current = current.AddDays( -1 ); + current = current.AddDays( -DateTime.DaysInMonth(current.Year, current.Month) + 1); + + break; + } return current; }