logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1169694 - /logging/log4net/trunk/src/Appender/EventLogAppender.cs
Date Mon, 12 Sep 2011 11:18:52 GMT
Author: bodewig
Date: Mon Sep 12 11:18:52 2011
New Revision: 1169694

URL: http://svn.apache.org/viewvc?rev=1169694&view=rev
Log:
Allow default value for event id to be specified via configuration.  LOG4NET-214

Modified:
    logging/log4net/trunk/src/Appender/EventLogAppender.cs

Modified: logging/log4net/trunk/src/Appender/EventLogAppender.cs
URL: http://svn.apache.org/viewvc/logging/log4net/trunk/src/Appender/EventLogAppender.cs?rev=1169694&r1=1169693&r2=1169694&view=diff
==============================================================================
--- logging/log4net/trunk/src/Appender/EventLogAppender.cs (original)
+++ logging/log4net/trunk/src/Appender/EventLogAppender.cs Mon Sep 12 11:18:52 2011
@@ -215,6 +215,22 @@ namespace log4net.Appender
 			set { m_securityContext = value; }
 		}
 
+        /// <summary>
+        /// Gets or sets the <c>EventId</c> to use unless one is explicitly specified
via the <c>LoggingEvent</c>'s properties.
+        /// </summary>
+        /// <remarks>
+        /// <para>
+        /// The <c>EventID</c> of the event log entry will normally be
+	    /// set using the <c>EventID</c> property (<see cref="LoggingEvent.Properties"/>)
+	    /// on the <see cref="LoggingEvent"/>.
+        /// This property provides the fallback value which defaults to 0.
+        /// </para>
+        /// </remarks>
+        public int EventId {
+            get { return m_eventId; }
+            set { m_eventId = value; }
+        }
+
 		#endregion // Public Instance Properties
 
 		#region Implementation of IOptionHandler
@@ -337,7 +353,7 @@ namespace log4net.Appender
 			//
 			// Write the resulting string to the event log system
 			//
-			int eventID = 0;
+			int eventID = m_eventId;
 
 			// Look for the EventLogEventID property
 			object eventIDPropertyObj = loggingEvent.LookupProperty("EventID");
@@ -479,6 +495,11 @@ namespace log4net.Appender
 		/// </summary>
 		private SecurityContext m_securityContext;
 
+        /// <summary>
+        /// The event ID to use unless one is explicitly specified via the <c>LoggingEvent</c>'s
properties.
+        /// </summary>
+        private int m_eventId = 0;
+
 		#endregion // Private Instance Fields
 
 		#region Level2EventLogEntryType LevelMapping Entry



Mime
View raw message