The default instrumented event raised by the WmiAppender

This is the default event fired by the WmiAppender. To fire a custom event set the WmiAppender.Layout to a subclass of WmiLayout that overrides the WmiLayout.CreateEvent method.

Наследование: System.Management.Instrumentation.BaseEvent
Пример #1
0
		/// <summary>
		/// Create the <see cref="IEvent"/> instance that should be fired
		/// </summary>
		/// <param name="loggingEvent">the <see cref="LoggingEvent"/> containing the data</param>
		/// <returns>an instrumentation event that can be fired</returns>
		/// <remarks>
		/// <para>
		/// The default implementation of this method creates a <see cref="WmiLoggingEvent"/>
		/// instance using the data from the <paramref name="loggingEvent" />.
		/// </para>
		/// <para>
		/// Subclasses should override this method to return their own custom 
		/// instrumentation event object.
		/// </para>
		/// </remarks>
		protected virtual IEvent CreateEvent(LoggingEvent loggingEvent)
		{
			WmiLoggingEvent wmiEvent = new WmiLoggingEvent();

			wmiEvent.TimeStamp = loggingEvent.TimeStamp;
			wmiEvent.LoggerName = loggingEvent.LoggerName;
			wmiEvent.Level = loggingEvent.Level.DisplayName;
			wmiEvent.Message = loggingEvent.RenderedMessage;
			wmiEvent.ThreadName = loggingEvent.ThreadName;
			wmiEvent.ExceptionString = loggingEvent.GetExceptionString();
			wmiEvent.Domain = loggingEvent.Domain;

			return wmiEvent;
		}
Пример #2
0
        /// <summary>
        /// Create the <see cref="IEvent"/> instance that should be fired
        /// </summary>
        /// <param name="loggingEvent">the <see cref="LoggingEvent"/> containing the data</param>
        /// <returns>an instrumentation event that can be fired</returns>
        /// <remarks>
        /// <para>
        /// The default implementation of this method creates a <see cref="WmiLoggingEvent"/>
        /// instance using the data from the <paramref name="loggingEvent" />.
        /// </para>
        /// <para>
        /// Subclasses should override this method to return their own custom
        /// instrumentation event object.
        /// </para>
        /// </remarks>
        protected virtual IEvent CreateEvent(LoggingEvent loggingEvent)
        {
            WmiLoggingEvent wmiEvent = new WmiLoggingEvent();

            wmiEvent.TimeStamp       = loggingEvent.TimeStamp;
            wmiEvent.LoggerName      = loggingEvent.LoggerName;
            wmiEvent.Level           = loggingEvent.Level.DisplayName;
            wmiEvent.Message         = loggingEvent.RenderedMessage;
            wmiEvent.ThreadName      = loggingEvent.ThreadName;
            wmiEvent.ExceptionString = loggingEvent.GetExceptionString();
            wmiEvent.Domain          = loggingEvent.Domain;

            return(wmiEvent);
        }