Log4net
  1. Log4net
  2. LOG4NET-214

EventLogAppender should also use config file to set EventId

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.10
    • Fix Version/s: 1.2.11
    • Component/s: Appenders
    • Labels:
      None

      Description

      It should be possible to set the EventId of the EventLogAppender using the config file.

      example:
      IT would like to be able to setup EventId for certain error without having to recompile the application:

      <appender name="EventLogAppender_Terminated" type="log4net.Appender.EventLogAppender" >
      <applicationName value="..." />
      <eventId value="1234" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="........." />
      </layout>
      <filter type="log4net.Filter.LevelRangeFilter">
      <levelMin value="ERROR" />
      </filter>
      <filter type="log4net.Filter.StringMatchFilter">
      <stringToMatch value="DatabaseException" />
      </filter>
      <filter type="log4net.Filter.DenyAllFilter" />
      </appender>

        Issue Links

          Activity

          Hide
          Vincent Guigui added a comment -

          The EventLogAppender.cs should be modified as followed

          /// <summary>
          /// The eventId to use when logging
          /// </summary>
          private int m_eventId;

          public int EventId
          {
          get

          { return m_eventId; }

          set

          { m_eventId = value; }

          }

          override protected void Append(LoggingEvent loggingEvent)
          {
          ...
          if (eventIDPropertyObj != null)

          { ... }

          else
          eventID = m_eventId;
          ...
          }

          Show
          Vincent Guigui added a comment - The EventLogAppender.cs should be modified as followed /// <summary> /// The eventId to use when logging /// </summary> private int m_eventId; public int EventId { get { return m_eventId; } set { m_eventId = value; } } override protected void Append(LoggingEvent loggingEvent) { ... if (eventIDPropertyObj != null) { ... } else eventID = m_eventId; ... }
          Hide
          Stefan Bodewig added a comment -

          fixed with svn revision 1169694

          Show
          Stefan Bodewig added a comment - fixed with svn revision 1169694

            People

            • Assignee:
              Unassigned
              Reporter:
              Vincent Guigui
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development