You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by Nicko Cadell <ni...@neoworks.com> on 2004/02/16 03:33:06 UTC
apache license 2.0
I have updated the log4net source in cvs to use the new apache license 2.0
The new license can be found here:
http://www.apache.org/licenses/LICENSE-2.0
Details on apache licensing can be found here:
http://www.apache.org/licenses
----
Nicko Cadell
Contributing/Bug#702507 - RollingFileAppender incorrectly chooses half day roll point
Posted by Dave Hutz <dh...@extreme-messaging.com>.
How do you submit a bug fix for this project?
My fix for the referenced bug is below...
Thanks,
Dave
/// <summary>
/// Calculates the RollPoint for the m_datePattern supplied.
/// </summary>
/// <returns>The RollPoint that is most accurate for the date pattern supplied</returns>
/// <remarks>
/// 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
/// 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()
{
if (m_datePattern != null)
{
// set date to 1970-01-01 00:00:00Z 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.
// Bug#702507 - this fails if you are in a timezone that is earlier than GMT
// Need to check both GMT and localtime.
DateTime epochA = DateTime.Parse("1970-01-01 00:00:00Z", System.Globalization.DateTimeFormatInfo.InvariantInfo);
DateTime epochB = DateTime.Parse("1970-01-01 00:00:00", System.Globalization.DateTimeFormatInfo.InvariantInfo);
// Get string representation of base line date
string r0A = epochA.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo);
string r0B = epochB.ToString(m_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++)
{
// Get string representation of next pattern
string r1A = NextCheckDate(epochA, (RollPoint)i).ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo);
string r1B = NextCheckDate(epochB, (RollPoint)i).ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo);
LogLog.Debug("RollingFileAppender: Type = ["+i+"], r0A = ["+r0A+"], r1A = ["+r1A+"]");
LogLog.Debug("RollingFileAppender: Type = ["+i+"], r0B = ["+r0B+"], r1B = ["+r1B+"]");
// Check if both the string representations are different
if (r0A != null && r1A != null && !r0A.Equals(r1A) &&
r0B != null && r1B != null && !r0B.Equals(r1B))
{
// Found highest precision roll point
return (RollPoint)i;
}
}
}
return RollPoint.TopOfTrouble; // Deliberately head for trouble...
}