[jira] [Created] (LOG4NET-368) PatternString properties in config file

2013-01-22 Thread Casul User (JIRA)
Casul User created LOG4NET-368:
--

 Summary: PatternString properties in config file
 Key: LOG4NET-368
 URL: https://issues.apache.org/jira/browse/LOG4NET-368
 Project: Log4net
  Issue Type: Improvement
  Components: Other
Reporter: Casul User
Priority: Minor


The PatternString has many built-in conversion patterns but none of them can 
use properties defined in the configuration file. The PatternString should also 
help to prevent copy paste errors and use the DRY pattern also in the config 
file. If you have many log files and they log in the same path, you would like 
to define the log path only once. If you want to change the log path, you would 
like to change it only in one place and not in many places.
Perhaps the most interesting converter is the property converter but you 
can't define global properties in the configuration file. The log4net global 
properties are nice but they are embedded in code and compiled with the 
application.

My suggestions are: Define log4net global properties in the configuration file:
log4net
 globalproperties
  add key=logpath value=c:\logs\myapplication\ /
 /globalproperties
 appender
  file value=%properties{logpath}log.txt /
 /appender
/log4net

Or add an appsettings converter to the PatternString:
appSettings
 add key=logpath value=c:\logs\myapplication\ /
/appSettings
log4net
 appender
  file value=%appsettings{logpath}log.txt /
 /appender
/log4net

There are also other cases where configuring part of the log path globally is 
useful, most of the time you have different environments: test, staging, 
production, demo, etc. and some times you have different type of the same 
environment: test-configuration1, test-configuration2, etc. So the ability to 
build the log file path from properties defined in the config file is an added 
value in those cases.
In those cases I have to set the properties only once in one place and I 
haven't to change the log file path of every logger, this would prevent errors 
like logger logging in the wrong place and it would simplify the deploy and 
configuration process.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


[jira] [Updated] (LOG4NET-27) Rolling files on date/time boundaries doesn't support a maximum number of backup files.

2013-01-22 Thread Hans Meier (JIRA)

 [ 
https://issues.apache.org/jira/browse/LOG4NET-27?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hans Meier updated LOG4NET-27:
--

Attachment: RollingFileAppender.zip

 Rolling files on date/time boundaries doesn't support a maximum number of 
 backup files.
 ---

 Key: LOG4NET-27
 URL: https://issues.apache.org/jira/browse/LOG4NET-27
 Project: Log4net
  Issue Type: New Feature
  Components: Appenders
Affects Versions: 1.2.11
Reporter: Florian Ramillien
Priority: Minor
 Fix For: 1.2 Maintenance Release

 Attachments: appender_diff, LOG4NET-27.patch, RollingFileAppender.cs, 
 RollingFileAppender.cs, RollingFileAppender.cs, RollingFileAppender.cs.patch, 
 rollingfileappender.diff, RollingFileAppender.patch, RollingFileAppender.zip


 A maximum of backup files exist when rolling files on file size, but not for 
 rolling on date/time.
 This can be implemented with the same config key : MaxSizeRollBackups

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


[PATCH 0 of 5 ] LOG4NET-27: Hans Meiers RFA patches

2013-01-22 Thread Dominik Psenner
I pasted the patched files into a series of patches and bomb them to the 
mailing list for eassier review.


[PATCH 1 of 5] Step 1: refactoring

2013-01-22 Thread Dominik Psenner
Trivial changes to tabs and spaces, formatting etc.

diff -r b430bc3cc0f4 -r dc18d71a5304 src/Appender/RollingFileAppender.cs
--- a/src/Appender/RollingFileAppender.cs   Tue Jan 22 14:27:20 2013 +0100
+++ b/src/Appender/RollingFileAppender.cs   Tue Jan 22 14:31:05 2013 +0100
@@ -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
@@ -31,12 +31,12 @@
// 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
 
@@ -68,34 +68,34 @@
/// itemInfinite 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.
@@ -110,7 +110,7 @@
/// 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.
@@ -123,10 +123,10 @@
/// authorDouglas de la Torre/author
/// authorEdward Smit/author
public class RollingFileAppender : FileAppender
-{
-#region Public Enums
+   {
+   #region Public Enums
 
-/// summary
+   /// summary
/// Style of rolling to use

[PATCH 2 of 5] Step 2: bugfix

2013-01-22 Thread Dominik Psenner
In RollOverIfDateBoundaryCrossing preserveLogFileExtension wasn't respected.

diff -r dc18d71a5304 -r 76c5f9136b8f src/Appender/RollingFileAppender.cs
--- a/src/Appender/RollingFileAppender.cs   Tue Jan 22 14:31:05 2013 +0100
+++ b/src/Appender/RollingFileAppender.cs   Tue Jan 22 14:31:24 2013 +0100
@@ -814,7 +814,7 @@
 
if 
(!(last.ToString(m_datePattern,System.Globalization.DateTimeFormatInfo.InvariantInfo).Equals(m_now.ToString(m_datePattern,
 System.Globalization.DateTimeFormatInfo.InvariantInfo
{
-   m_scheduledFilename = 
m_baseFileName + last.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+]);
RollOverTime(false);
LogLog.Debug(declaringType, 
curSizeRollBackups after rollOver at [+m_curSizeRollBackups+]);


[PATCH 3 of 5] Step 3: modifications without affecting existing code

2013-01-22 Thread Dominik Psenner
* some trivial changes in visibility, regions etc.
* additional functions, properties, members that aren't yet used from existing 
code.
* NextCheckDate - GetRollDateTimeRelative:
  Function works identically if called with relativePeriod==1. Existing code 
does this.
  Additionally any count of positive or negative period jumps can be calculated.
* Fully isolated getting last write time in a function GetLastWriteTime
* Split CombinePath into a static version and a member function to call it. 
Needed
  to allow implementing and testing one of the new functions as static function.
  That new, static function uses CombinePath so i needed a static version.

diff -r 76c5f9136b8f -r 569e06c6cfb3 src/Appender/RollingFileAppender.cs
--- a/src/Appender/RollingFileAppender.cs   Tue Jan 22 14:31:24 2013 +0100
+++ b/src/Appender/RollingFileAppender.cs   Tue Jan 22 14:31:43 2013 +0100
@@ -169,10 +169,6 @@
Composite   = 3
}
 
-   #endregion
-
-   #region Protected Enums
-
/// summary
/// The code assumes that the following 'time' constants are in 
a increasing sequence.
/// /summary
@@ -181,7 +177,7 @@
/// The code assumes that the following 'time' constants are in 
a increasing sequence.
/// /para
/// /remarks
-   protected enum RollPoint
+   public enum RollPoint
{
/// summary
/// Roll the log not based on the date
@@ -219,7 +215,7 @@
TopOfMonth  = 5
}
 
-   #endregion Protected Enums
+   #endregion Public Enums
 
#region Public Instance Constructors
 
@@ -339,6 +335,35 @@
}
 
/// summary
+   /// Gets or sets the maximum number of periods to keep backups 
for.
+   /// /summary
+   /// value
+   /// The maximum number of periods to keep backups for.
+   /// /value
+   /// remarks
+   /// para
+   /// The value refers to the count of periods backups shall be 
kept for. Any 
+   /// backups that are older than MaxDateRollBackups * Period get 
deleted,
+   /// regardless whether or how many backups exist younger than 
this exist. 
+   /// /para
+   /// para
+   /// Example: If set to 10 and roll pattern is daily everything 
older than 10 
+   /// days gets deleted.  
+   /// /para
+   /// para
+   /// If set to zero, then there will be no time roll backup 
files.
+   /// /para
+   /// para
+   /// If a negative number is supplied then no deletions will be 
made.
+   /// /para
+   /// /remarks
+   public int MaxDateRollBackups
+   {
+   get { return m_maxDateRollBackups; }
+   set { m_maxDateRollBackups = value; }
+   }
+
+   /// summary
/// Gets or sets the maximum size that the output file is 
allowed to reach
/// before being rolled over to backup files.
/// /summary
@@ -598,7 +623,7 @@
if (n = m_nextCheck)
{
m_now = n;
-   m_nextCheck = NextCheckDate(m_now, 
m_rollPoint);
+   m_nextCheck = 
GetRollDateTimeRelative(m_now, m_rollPoint, 1);
 
RollOverTime(true);
}
@@ -797,18 +822,7 @@
DateTime last;
using(SecurityContext.Impersonate(this))
{
-#if !NET_1_0  !CLI_1_0  !NETCF
-   if (DateTimeStrategy is 
UniversalDateTime)
-   {
-   last = 
System.IO.File.GetLastWriteTimeUtc(m_baseFileName);
-   }
-   else
-   {
-#endif
-   last = 
System.IO.File.GetLastWriteTime(m_baseFileName);
-#if !NET_1_0  !CLI_1_0  !NETCF
-   }
-#endif
+   last = 
GetLastWriteTime(m_baseFileName);
}
LogLog.Debug(declaringType, 
[+last.ToString(m_datePattern,System.Globalization.DateTimeFormatInfo.InvariantInfo)+]
 vs. 

[PATCH 4 of 5] Step 4: use the new functionality

2013-01-22 Thread Dominik Psenner
diff -r 569e06c6cfb3 -r c4b727dc790c src/Appender/RollingFileAppender.cs
--- a/src/Appender/RollingFileAppender.cs   Tue Jan 22 14:31:43 2013 +0100
+++ b/src/Appender/RollingFileAppender.cs   Tue Jan 22 14:31:58 2013 +0100
@@ -835,6 +835,11 @@
}
}
}
+
+   if (m_rollDate)
+   {
+   DeleteOutdatedFiles();
+   }
}
 
/// summary
@@ -1243,12 +1248,18 @@
{
string from = CombinePath(File, . + 
i);
string to = 
CombinePath(m_scheduledFilename, . + i);
-   RollFile(from, to);
+   if (FileExists(from)) // to avoid file 
not exists warning because that's legal here
+   {
+   RollFile(from, to);
+   }
}
 
RollFile(File, m_scheduledFilename);
}
 
+   //Now we delete files too old to keep (see 
m_maxDateRollBackups)
+   DeleteOutdatedFiles();
+
//We've cleared out the old date and are ready for the 
new
m_curSizeRollBackups = 0;
 


[PATCH 5 of 5] Step 5: tests

2013-01-22 Thread Dominik Psenner
diff -r c4b727dc790c -r 09c42c61e2db 
tests/src/Appender/RollingFileAppenderTest.cs
--- a/tests/src/Appender/RollingFileAppenderTest.cs Tue Jan 22 14:31:58 
2013 +0100
+++ b/tests/src/Appender/RollingFileAppenderTest.cs Tue Jan 22 14:37:21 
2013 +0100
@@ -1874,12 +1874,110 @@
{
}
 
+/// summary
+/// 
+/// /summary
+[Test]
+public void TestGetFileDeleteList1()
+{
+string[] files = {   C:\\foo\\log.201302.log, 
C:\\foo\\log.201302.1.log, C:\\foo\\log.201302.2.log, 
+ C:\\foo\\log.201301.log, 
C:\\foo\\log.201301.1.log, C:\\foo\\log.201301.2.log,
+ C:\\foo\\log.201212.log, 
C:\\foo\\log.201212.1.log, C:\\foo\\log.201212.2.log,  
+ C:\\foo\\log.201211.log, 
C:\\foo\\log.201211.1.log, C:\\foo\\log.201211.2.log };
+string[] actual = GetFileDeleteList(files, 
DateTime.Parse(2013/02/15), C:\\foo\\log.log, .MM, 
+RollingFileAppender.RollPoint.TopOfMonth, 2, true);
+string[] expected = { C:\\foo\\log.201211.log, 
C:\\foo\\log.201211.1.log, C:\\foo\\log.201211.2.log };
+Assert.AreEqual(expected, actual);
+}
 
-   //
+/// summary
+/// 
+/// /summary
+[Test]
+public void TestGetFileDeleteList2()
+{
+string[] files = {   C:\\foo\\log.201302.log, 
C:\\foo\\log.201302.1.log, C:\\foo\\log.201302.2.log, 
+ C:\\foo\\log.201301.log, 
C:\\foo\\log.201301.1.log, C:\\foo\\log.201301.2.log,
+ C:\\foo\\log.201212.log, 
C:\\foo\\log.201212.1.log, C:\\foo\\log.201212.2.log,  
+ C:\\foo\\log.201211.log, 
C:\\foo\\log.201211.1.log, C:\\foo\\log.201211.2.log };
+string[] actual = GetFileDeleteList(files, 
DateTime.Parse(2013/02/15), C:\\foo\\log.log, .MM,
+RollingFileAppender.RollPoint.TopOfMonth, 0, true);
+string[] expected = {C:\\foo\\log.201301.log, 
C:\\foo\\log.201301.1.log, C:\\foo\\log.201301.2.log,
+ C:\\foo\\log.201212.log, 
C:\\foo\\log.201212.1.log, C:\\foo\\log.201212.2.log,  
+ C:\\foo\\log.201211.log, 
C:\\foo\\log.201211.1.log, C:\\foo\\log.201211.2.log };
+Assert.AreEqual(expected, actual);
+}
+
+/// summary
+/// 
+/// /summary
+[Test]
+public void TestGetFileDeleteList3()
+{
+string[] files = {   C:\\foo\\log.log.2013.2, 
C:\\foo\\log.log.2013.2.1, C:\\foo\\log.log.2013.2.2, 
+ C:\\foo\\log.log.2013.1, 
C:\\foo\\log.log.2013.1.1, C:\\foo\\log.log.2013.1.2,
+ C:\\foo\\log.log.2012.12, 
C:\\foo\\log.log.2012.12.1, C:\\foo\\log.log.2012.12.2,  
+ C:\\foo\\log.log.2012.11, 
C:\\foo\\log.log.2012.11.1, C:\\foo\\log.log.2012.11.2 };
+string[] actual = GetFileDeleteList(files, 
DateTime.Parse(2013/02/15), C:\\foo\\log.log, ..M,
+RollingFileAppender.RollPoint.TopOfMonth, 2, false);
+string[] expected = { C:\\foo\\log.log.2012.11, 
C:\\foo\\log.log.2012.11.1, C:\\foo\\log.log.2012.11.2 };
+Assert.AreEqual(expected, actual);
+}
+
+/// summary
+/// 
+/// /summary
+[Test]
+public void TestGetFileDeleteList4()
+{
+string[] files = {   C:\\foo\\log.2.2013.log, 
C:\\foo\\log.2.2013.1.log, C:\\foo\\log.2.2013.2.log, 
+ C:\\foo\\log.1.2013.log, 
C:\\foo\\log.1.2013.1.log, C:\\foo\\log.1.2013.2.log,
+ C:\\foo\\log.12.2012.log, 
C:\\foo\\log.12.2012.1.log, C:\\foo\\log.12.2012.2.log };
+string[] actual = GetFileDeleteList(files, 
DateTime.Parse(2013/02/15), C:\\foo\\log.log, .M.,
+RollingFileAppender.RollPoint.TopOfMonth, 0, true);
+string[] expected = { C:\\foo\\log.1.2013.log, 
C:\\foo\\log.1.2013.1.log, C:\\foo\\log.1.2013.2.log,
+  C:\\foo\\log.12.2012.log, 
C:\\foo\\log.12.2012.1.log, C:\\foo\\log.12.2012.2.log};
+Assert.AreEqual(expected, actual);
+}
+
+//
// Helper functions to dig into the appender
//
+protected class TestDateTime : RollingFileAppender.IDateTime
+{
+public TestDateTime(DateTime dt)
+{
+m_Now = dt;
+}
 
-   private static ArrayList GetExistingFiles(string baseFilePath)
+#region IDateTime Members
+
+public DateTime Now
+{
+get { return m_Now; }
+}
+
+#endregion
+
+private DateTime m_Now;
+}
+
+protected static 

RE: [PATCH 1 of 5] Step 1: refactoring

2013-01-22 Thread Dominik Psenner
Quite a large patch, but looks sensible.

-Original Message-
From: Dominik Psenner [mailto:dpsen...@gmail.com]
Sent: Tuesday, January 22, 2013 2:41 PM
To: log4net-dev@logging.apache.org
Subject: [PATCH 1 of 5] Step 1: refactoring

Trivial changes to tabs and spaces, formatting etc.

diff -r b430bc3cc0f4 -r dc18d71a5304 src/Appender/RollingFileAppender.cs
--- a/src/Appender/RollingFileAppender.cs  Tue Jan 22 14:27:20 2013
+0100
+++ b/src/Appender/RollingFileAppender.cs  Tue Jan 22 14:31:05 2013
+0100
@@ -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
@@ -31,12 +31,12 @@
   // 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

@@ -68,34 +68,34 @@
   /// itemInfinite 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.
@@ -110,7 +110,7 @@
   /// 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.
@@ -123,10 +123,10 @@
   /// authorDouglas de la Torre/author
   /// authorEdward Smit/author
   public class RollingFileAppender : FileAppender
-{
-#region Public Enums
+  {
+  #region 

Re: [PATCH 2 of 5] Step 2: bugfix

2013-01-22 Thread Dominik Psenner

What are the effects of this bug? It is not yet reported as an issue, is it?

On 01/22/2013 02:41 PM, Dominik Psenner wrote:

In RollOverIfDateBoundaryCrossing preserveLogFileExtension wasn't respected.

diff -r dc18d71a5304 -r 76c5f9136b8f src/Appender/RollingFileAppender.cs
--- a/src/Appender/RollingFileAppender.cs   Tue Jan 22 14:31:05 2013 +0100
+++ b/src/Appender/RollingFileAppender.cs   Tue Jan 22 14:31:24 2013 +0100
@@ -814,7 +814,7 @@
  
  	if (!(last.ToString(m_datePattern,System.Globalization.DateTimeFormatInfo.InvariantInfo).Equals(m_now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo

{
-   m_scheduledFilename = 
m_baseFileName + last.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+]);
RollOverTime(false);
LogLog.Debug(declaringType, 
curSizeRollBackups after rollOver at [+m_curSizeRollBackups+]);


Re: [PATCH 5 of 5] Step 5: tests

2013-01-22 Thread Dominik Psenner

On 01/22/2013 02:41 PM, Dominik Psenner wrote:

diff -r c4b727dc790c -r 09c42c61e2db 
tests/src/Appender/RollingFileAppenderTest.cs
--- a/tests/src/Appender/RollingFileAppenderTest.cs Tue Jan 22 14:31:58 
2013 +0100
+++ b/tests/src/Appender/RollingFileAppenderTest.cs Tue Jan 22 14:37:21 
2013 +0100
@@ -1874,12 +1874,110 @@
{
}
  
+/// summary

+///
+/// /summary
+[Test]
+public void TestGetFileDeleteList1()
+{
+string[] files = {   C:\\foo\\log.201302.log, C:\\foo\\log.201302.1.log, 
C:\\foo\\log.201302.2.log,
+ C:\\foo\\log.201301.log, C:\\foo\\log.201301.1.log, 
C:\\foo\\log.201301.2.log,
+ C:\\foo\\log.201212.log, C:\\foo\\log.201212.1.log, 
C:\\foo\\log.201212.2.log,
+ C:\\foo\\log.201211.log, C:\\foo\\log.201211.1.log, 
C:\\foo\\log.201211.2.log };
+string[] actual = GetFileDeleteList(files, DateTime.Parse(2013/02/15), 
C:\\foo\\log.log, .MM,
+RollingFileAppender.RollPoint.TopOfMonth, 2, true);
+string[] expected = { C:\\foo\\log.201211.log, 
C:\\foo\\log.201211.1.log, C:\\foo\\log.201211.2.log };
+Assert.AreEqual(expected, actual);
+}
  
-		//

+/// summary
+///
+/// /summary
+[Test]
+public void TestGetFileDeleteList2()
+{
+string[] files = {   C:\\foo\\log.201302.log, C:\\foo\\log.201302.1.log, 
C:\\foo\\log.201302.2.log,
+ C:\\foo\\log.201301.log, C:\\foo\\log.201301.1.log, 
C:\\foo\\log.201301.2.log,
+ C:\\foo\\log.201212.log, C:\\foo\\log.201212.1.log, 
C:\\foo\\log.201212.2.log,
+ C:\\foo\\log.201211.log, C:\\foo\\log.201211.1.log, 
C:\\foo\\log.201211.2.log };
+string[] actual = GetFileDeleteList(files, DateTime.Parse(2013/02/15), 
C:\\foo\\log.log, .MM,
+RollingFileAppender.RollPoint.TopOfMonth, 0, true);
+string[] expected = {C:\\foo\\log.201301.log, C:\\foo\\log.201301.1.log, 
C:\\foo\\log.201301.2.log,
+ C:\\foo\\log.201212.log, C:\\foo\\log.201212.1.log, 
C:\\foo\\log.201212.2.log,
+ C:\\foo\\log.201211.log, C:\\foo\\log.201211.1.log, 
C:\\foo\\log.201211.2.log };
+Assert.AreEqual(expected, actual);
+}
+
+/// summary
+///
+/// /summary
+[Test]
+public void TestGetFileDeleteList3()
+{
+string[] files = {   C:\\foo\\log.log.2013.2, C:\\foo\\log.log.2013.2.1, 
C:\\foo\\log.log.2013.2.2,
+ C:\\foo\\log.log.2013.1, C:\\foo\\log.log.2013.1.1, 
C:\\foo\\log.log.2013.1.2,
+ C:\\foo\\log.log.2012.12, 
C:\\foo\\log.log.2012.12.1, C:\\foo\\log.log.2012.12.2,
+ C:\\foo\\log.log.2012.11, 
C:\\foo\\log.log.2012.11.1, C:\\foo\\log.log.2012.11.2 };
+string[] actual = GetFileDeleteList(files, DateTime.Parse(2013/02/15), 
C:\\foo\\log.log, ..M,
+RollingFileAppender.RollPoint.TopOfMonth, 2, false);
+string[] expected = { C:\\foo\\log.log.2012.11, 
C:\\foo\\log.log.2012.11.1, C:\\foo\\log.log.2012.11.2 };
+Assert.AreEqual(expected, actual);
+}
+
+/// summary
+///
+/// /summary
+[Test]
+public void TestGetFileDeleteList4()
+{
+string[] files = {   C:\\foo\\log.2.2013.log, C:\\foo\\log.2.2013.1.log, 
C:\\foo\\log.2.2013.2.log,
+ C:\\foo\\log.1.2013.log, C:\\foo\\log.1.2013.1.log, 
C:\\foo\\log.1.2013.2.log,
+ C:\\foo\\log.12.2012.log, 
C:\\foo\\log.12.2012.1.log, C:\\foo\\log.12.2012.2.log };
+string[] actual = GetFileDeleteList(files, DateTime.Parse(2013/02/15), 
C:\\foo\\log.log, .M.,
+RollingFileAppender.RollPoint.TopOfMonth, 0, true);
+string[] expected = { C:\\foo\\log.1.2013.log, 
C:\\foo\\log.1.2013.1.log, C:\\foo\\log.1.2013.2.log,
+  C:\\foo\\log.12.2012.log, 
C:\\foo\\log.12.2012.1.log, C:\\foo\\log.12.2012.2.log};
+Assert.AreEqual(expected, actual);
+}
+
+//
// Helper functions to dig into the appender
//
+protected class TestDateTime : RollingFileAppender.IDateTime
+{
+public TestDateTime(DateTime dt)
+{
+m_Now = dt;
+}
  
-		private static ArrayList GetExistingFiles(string baseFilePath)

+#region IDateTime Members
+
+public DateTime Now
+{
+get { return m_Now; }
+}
+
+#endregion
+
+private DateTime m_Now;
+}
+
+protected 

Re: [PATCH 4 of 5] Step 4: use the new functionality

2013-01-22 Thread Dominik Psenner

On 01/22/2013 02:41 PM, Dominik Psenner wrote:

diff -r 569e06c6cfb3 -r c4b727dc790c src/Appender/RollingFileAppender.cs
--- a/src/Appender/RollingFileAppender.cs   Tue Jan 22 14:31:43 2013 +0100
+++ b/src/Appender/RollingFileAppender.cs   Tue Jan 22 14:31:58 2013 +0100
@@ -835,6 +835,11 @@
}
}
}
+
+   if (m_rollDate)
+   {
+   DeleteOutdatedFiles();
+   }
}
  
  		/// summary

@@ -1243,12 +1248,18 @@
{
string from = CombinePath(File, . + 
i);
string to = CombinePath(m_scheduledFilename, 
. + i);
-   RollFile(from, to);
+   if (FileExists(from)) // to avoid file 
not exists warning because that's legal here
+   {
+   RollFile(from, to);
+   }
}
  
  RollFile(File, m_scheduledFilename);

}
  
+			//Now we delete files too old to keep (see m_maxDateRollBackups)

+   DeleteOutdatedFiles();
+
//We've cleared out the old date and are ready for the 
new
m_curSizeRollBackups = 0;
  
This patch does not make sense without the previous patch. So the 
functionality is basically hidden in the previous patch that claims to 
be doing nothing. I'm aborting the review here. Please split the patches 
into as many pieces as needed so that they are easily review-able. That 
would be great!


[jira] [Commented] (LOG4NET-27) Rolling files on date/time boundaries doesn't support a maximum number of backup files.

2013-01-22 Thread Dominik Psenner (JIRA)

[ 
https://issues.apache.org/jira/browse/LOG4NET-27?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13559795#comment-13559795
 ] 

Dominik Psenner commented on LOG4NET-27:


Hi Hans. Thanks for your help! Unfortunately the patch you provided is too 
blown up to be reviewed easily. I reviewed it on the devel mailing list as far 
as I was able to. Would you please check the mailing list messages and let us 
know what you think?

 Rolling files on date/time boundaries doesn't support a maximum number of 
 backup files.
 ---

 Key: LOG4NET-27
 URL: https://issues.apache.org/jira/browse/LOG4NET-27
 Project: Log4net
  Issue Type: New Feature
  Components: Appenders
Affects Versions: 1.2.11
Reporter: Florian Ramillien
Priority: Minor
 Fix For: 1.2 Maintenance Release

 Attachments: appender_diff, LOG4NET-27.patch, RollingFileAppender.cs, 
 RollingFileAppender.cs, RollingFileAppender.cs, RollingFileAppender.cs.patch, 
 rollingfileappender.diff, RollingFileAppender.patch, RollingFileAppender.zip


 A maximum of backup files exist when rolling files on file size, but not for 
 rolling on date/time.
 This can be implemented with the same config key : MaxSizeRollBackups

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


Re: Re: [PATCH 2 of 5] Step 2: bugfix

2013-01-22 Thread h . s . meier
Consider this configuration, with V 1.2.11 or trunk:

file value=log.log /
appendToFile value=true /
rollingStyle value=Composite /
datePattern value=.MMdd-HHmm /
staticLogFileName value=true /
preserveLogFileNameExtension value=true /

* Start an application (a verbose one, preferably) with it.

* Kill it immediately.
  Log directory now looks like this
  ---
  log.log
  ---

* Wait until we are in another minute

* Start application again

* Kill it immediately
  Log directory now looks like this
  ---
  log.log
  log.log.20130122-2042
  ---

Didn't we say we want to preserveLogFileNameExtension?
Shouldn't the file name of the file rolled over be log.20130122-2042.log?
If the application weren't killed and restarted in another period,
everything were correct.

This happens when rolling over an old log file from a previous run upon 
application start. The line of this patch fixes it. Obviously the one who once 
extracted the function CombinePath to always correctly consider the setting of 
preserveLogFileNameExtension simply overlooked this one occurrence of file name 
combining.

AFAIK this hasn't been reported yet.



 What are the effects of this bug? It is not yet reported as an issue, is it?

 On 01/22/2013 02:41 PM, Dominik Psenner wrote:
 In RollOverIfDateBoundaryCrossing preserveLogFileExtension wasn't respected.

 diff -r dc18d71a5304 -r 76c5f9136b8f src/Appender/RollingFileAppender.cs
 --- a/src/Appender/RollingFileAppender.csTue Jan 22 14:31:05 2013 +0100
 +++ b/src/Appender/RollingFileAppender.csTue Jan 22 14:31:24 2013 +0100
 @@ -814,7 +814,7 @@

   if 
 (!(last.ToString(m_datePattern,System.Globalization.DateTimeFormatInfo.InvariantInfo).Equals(m_now.ToString(m_datePattern,
  System.Globalization.DateTimeFormatInfo.InvariantInfo
   {
 -m_scheduledFilename = m_baseFileName + 
 last.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+]);
   RollOverTime(false);
   LogLog.Debug(declaringType, curSizeRollBackups 
 after rollOver at [+m_curSizeRollBackups+]);



RE: Re: [PATCH 2 of 5] Step 2: bugfix

2013-01-22 Thread Dominik Psenner
Thanks for the infos.

Cheers,
Dominik

-Original Message-
From: h.s.me...@arcor.de [mailto:h.s.me...@arcor.de]
Sent: Tuesday, January 22, 2013 9:31 PM
To: log4net-dev@logging.apache.org
Subject: Re: Re: [PATCH 2 of 5] Step 2: bugfix

Consider this configuration, with V 1.2.11 or trunk:

file value=log.log /
appendToFile value=true /
rollingStyle value=Composite /
datePattern value=.MMdd-HHmm /
staticLogFileName value=true /
preserveLogFileNameExtension value=true /

* Start an application (a verbose one, preferably) with it.

* Kill it immediately.
  Log directory now looks like this
  ---
  log.log
  ---

* Wait until we are in another minute

* Start application again

* Kill it immediately
  Log directory now looks like this
  ---
  log.log
  log.log.20130122-2042
  ---

Didn't we say we want to preserveLogFileNameExtension?
Shouldn't the file name of the file rolled over be log.20130122-2042.log?
If the application weren't killed and restarted in another period,
everything were correct.

This happens when rolling over an old log file from a previous run upon 
application start. The line
of this patch fixes it. Obviously the one who once extracted the function 
CombinePath to always
correctly consider the setting of preserveLogFileNameExtension simply 
overlooked this one
occurrence of file name combining.

AFAIK this hasn't been reported yet.



 What are the effects of this bug? It is not yet reported as an issue, is it?

 On 01/22/2013 02:41 PM, Dominik Psenner wrote:
 In RollOverIfDateBoundaryCrossing preserveLogFileExtension wasn't respected.

 diff -r dc18d71a5304 -r 76c5f9136b8f src/Appender/RollingFileAppender.cs
 --- a/src/Appender/RollingFileAppender.csTue Jan 22 14:31:05 2013 +0100
 +++ b/src/Appender/RollingFileAppender.csTue Jan 22 14:31:24 2013 +0100
 @@ -814,7 +814,7 @@

   if
(!(last.ToString(m_datePattern,System.Globalization.DateTimeFormatInfo.InvariantInfo).Equals(m_now.
ToString(m_datePattern, 
System.Globalization.DateTimeFormatInfo.InvariantInfo
   {
 -m_scheduledFilename = m_baseFileName + 
 last.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+]);
   RollOverTime(false);
   LogLog.Debug(declaringType, curSizeRollBackups 
 after rollOver at
[+m_curSizeRollBackups+]);




RE: [PATCH 1 of 5] Step 1: refactoring

2013-01-22 Thread Dominik Psenner
Do you expect any response from other devs?

No.

In case you do, we practice CTR (Commit then review). If you are happy
with the patches, then just apply them to the code. If you are not
happy / in doubt, get to the ML. No need to wait for a second
confirmation :-)

I'm expecting feedback from the writer of the patch. There is too much 
background noise of unrelated changes in the patch and I hope
that untangling the important parts could resolve LOG4NET-27. And last but not 
least I'm trying to get other people involved. :-)

Cheers,
Dominik



[jira] [Created] (LOG4NET-369) preserveLogFileNameExtension is not considered when rolling over time after an application restart

2013-01-22 Thread Dominik Psenner (JIRA)
Dominik Psenner created LOG4NET-369:
---

 Summary: preserveLogFileNameExtension is not considered when 
rolling over time after an application restart
 Key: LOG4NET-369
 URL: https://issues.apache.org/jira/browse/LOG4NET-369
 Project: Log4net
  Issue Type: Bug
  Components: Appenders
Affects Versions: 1.2.9
Reporter: Dominik Psenner
Assignee: Dominik Psenner
Priority: Minor
 Fix For: 1.2.12


Consider this configuration, with V 1.2.11 or trunk:

file value=log.log /
appendToFile value=true /
rollingStyle value=Composite /
datePattern value=.MMdd-HHmm /
staticLogFileName value=true /
preserveLogFileNameExtension value=true /

* Start an application (a verbose one, preferably) with it.

* Kill it immediately.
  Log directory now looks like this
  ---
  log.log
  ---

* Wait until we are in another minute

* Start application again

* Kill it immediately
  Log directory now looks like this
  ---
  log.log
  log.log.20130122-2042
  ---

Didn't we say we want to preserveLogFileNameExtension?
Shouldn't the file name of the file rolled over be log.20130122-2042.log?
If the application weren't killed and restarted in another period,
everything were correct.

This happens when rolling over an old log file from a previous run upon 
application start. The line of this patch fixes it.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


[jira] [Commented] (LOG4NET-369) preserveLogFileNameExtension is not considered when rolling over time after an application restart

2013-01-22 Thread Dominik Psenner (JIRA)

[ 
https://issues.apache.org/jira/browse/LOG4NET-369?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13560454#comment-13560454
 ] 

Dominik Psenner commented on LOG4NET-369:
-

Patch commited as revision: 1437281

 preserveLogFileNameExtension is not considered when rolling over time after 
 an application restart
 --

 Key: LOG4NET-369
 URL: https://issues.apache.org/jira/browse/LOG4NET-369
 Project: Log4net
  Issue Type: Bug
  Components: Appenders
Affects Versions: 1.2.9
Reporter: Dominik Psenner
Assignee: Dominik Psenner
Priority: Minor
 Fix For: 1.2.12


 Consider this configuration, with V 1.2.11 or trunk:
 file value=log.log /
 appendToFile value=true /
 rollingStyle value=Composite /
 datePattern value=.MMdd-HHmm /
 staticLogFileName value=true /
 preserveLogFileNameExtension value=true /
 * Start an application (a verbose one, preferably) with it.
 * Kill it immediately.
   Log directory now looks like this
   ---
   log.log
   ---
 * Wait until we are in another minute
 * Start application again
 * Kill it immediately
   Log directory now looks like this
   ---
   log.log
   log.log.20130122-2042
   ---
 Didn't we say we want to preserveLogFileNameExtension?
 Shouldn't the file name of the file rolled over be log.20130122-2042.log?
 If the application weren't killed and restarted in another period,
 everything were correct.
 This happens when rolling over an old log file from a previous run upon 
 application start. The line of this patch fixes it.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


[jira] [Resolved] (LOG4NET-369) preserveLogFileNameExtension is not considered when rolling over time after an application restart

2013-01-22 Thread Dominik Psenner (JIRA)

 [ 
https://issues.apache.org/jira/browse/LOG4NET-369?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dominik Psenner resolved LOG4NET-369.
-

Resolution: Fixed

 preserveLogFileNameExtension is not considered when rolling over time after 
 an application restart
 --

 Key: LOG4NET-369
 URL: https://issues.apache.org/jira/browse/LOG4NET-369
 Project: Log4net
  Issue Type: Bug
  Components: Appenders
Affects Versions: 1.2.9
Reporter: Dominik Psenner
Assignee: Dominik Psenner
Priority: Minor
 Fix For: 1.2.12


 Consider this configuration, with V 1.2.11 or trunk:
 file value=log.log /
 appendToFile value=true /
 rollingStyle value=Composite /
 datePattern value=.MMdd-HHmm /
 staticLogFileName value=true /
 preserveLogFileNameExtension value=true /
 * Start an application (a verbose one, preferably) with it.
 * Kill it immediately.
   Log directory now looks like this
   ---
   log.log
   ---
 * Wait until we are in another minute
 * Start application again
 * Kill it immediately
   Log directory now looks like this
   ---
   log.log
   log.log.20130122-2042
   ---
 Didn't we say we want to preserveLogFileNameExtension?
 Shouldn't the file name of the file rolled over be log.20130122-2042.log?
 If the application weren't killed and restarted in another period,
 everything were correct.
 This happens when rolling over an old log file from a previous run upon 
 application start. The line of this patch fixes it.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


[jira] [Closed] (LOG4NET-369) preserveLogFileNameExtension is not considered when rolling over time after an application restart

2013-01-22 Thread Dominik Psenner (JIRA)

 [ 
https://issues.apache.org/jira/browse/LOG4NET-369?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dominik Psenner closed LOG4NET-369.
---


 preserveLogFileNameExtension is not considered when rolling over time after 
 an application restart
 --

 Key: LOG4NET-369
 URL: https://issues.apache.org/jira/browse/LOG4NET-369
 Project: Log4net
  Issue Type: Bug
  Components: Appenders
Affects Versions: 1.2.9
Reporter: Dominik Psenner
Assignee: Dominik Psenner
Priority: Minor
 Fix For: 1.2.12


 Consider this configuration, with V 1.2.11 or trunk:
 file value=log.log /
 appendToFile value=true /
 rollingStyle value=Composite /
 datePattern value=.MMdd-HHmm /
 staticLogFileName value=true /
 preserveLogFileNameExtension value=true /
 * Start an application (a verbose one, preferably) with it.
 * Kill it immediately.
   Log directory now looks like this
   ---
   log.log
   ---
 * Wait until we are in another minute
 * Start application again
 * Kill it immediately
   Log directory now looks like this
   ---
   log.log
   log.log.20130122-2042
   ---
 Didn't we say we want to preserveLogFileNameExtension?
 Shouldn't the file name of the file rolled over be log.20130122-2042.log?
 If the application weren't killed and restarted in another period,
 everything were correct.
 This happens when rolling over an old log file from a previous run upon 
 application start. The line of this patch fixes it.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira