Log4net
  1. Log4net
  2. LOG4NET-165

RollingFileAppender file names do not support UTC

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.10
    • Fix Version/s: 1.2 Maintenance Release
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows Vista

      Description

      There seems to be not way to use UTC dates for RollingFileAppenders names.

      In my case :

      RollingFileAppender rfa = new RollingFileAppender();
      rfa.DatePattern = "yyyy-MM-dd HH";
      rfa.RollingStyle = RollingFileAppender.RollingMode.Date;
      rfa.StaticLogFileName = false;
      PatternLayout layout = new PatternLayout("%utcdate %m%n");

      I managed to get the log lines in UTC, but not the log file names.

      I could got it by a quick & dirty implementation of a UTCRollingFileAppender with custom constructor :

      public UTCRollingFileAppender()

      { m_dateTime = new UniversalDateTime(); }

      And IDateTime implementation :

      /// <summary>
      /// Universal Time Zone implementation of <see cref="IDateTime"/> that returns the current time.
      /// </summary>
      private class UniversalDateTime : IDateTime
      {
      /// <summary>
      /// Gets the <b>current</b> time.
      /// </summary>
      /// <value>The <b>current</b> time.</value>
      /// <remarks>
      /// <para>
      /// Gets the <b>current</b> time.
      /// </para>
      /// </remarks>
      public DateTime Now
      {
      get

      { return DateTime.UtcNow; }

      }
      }

      I believe I could have missed something in the configuration.
      If this is not the case, would it be possible to implement it in a clean way ?

      Regards,
      Miguel

        Issue Links

          Activity

          No work has yet been logged on this issue.

            People

            • Assignee:
              Unassigned
              Reporter:
              Miguel L
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Development