public override void Write(string message)
        {
            LogEntry logEntry = new LogEntry();

            logEntry.Message = message;
            ManagementInstrumentation.Fire(logEntry);
        }
 public void AuthorizationCheckPerformed(object sender, AuthorizationOperationEventArgs e)
 {
     if (PerformanceCountersEnabled)
     {
         authorizationCheckPerformedCounter.Increment();
     }
     if (WmiEnabled)
     {
         ManagementInstrumentation.Fire(new AuthorizationCheckPerformedEvent(instanceName, e.Identity, e.RuleName));
     }
 }
Esempio n. 3
0
 public void HashMismatchDetected(object sender, EventArgs e)
 {
     if (PerformanceCountersEnabled)
     {
         hashMismatchDetectedCounter.Increment();
     }
     if (WmiEnabled)
     {
         ManagementInstrumentation.Fire(new HashMismatchDetectedEvent(instanceName));
     }
 }
 public void SecurityCacheReadPerformed(object sender, SecurityCacheOperationEventArgs e)
 {
     if (PerformanceCountersEnabled)
     {
         securityCacheReadPerformedCounter.Increment();
     }
     if (WmiEnabled)
     {
         ManagementInstrumentation.Fire(new SecurityCacheReadPerformedEvent(instanceName, e.ItemType.ToString(), (e.Token == null) ? string.Empty : e.Token.Value));
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Logs the occurrence of an internal error for the Enterprise Library Exception Handling Application Block through the
 /// available instrumentation mechanisms.
 /// </summary>
 /// <param name="policyName">The name of the Exception policy in which the error was occurred.</param>
 /// <param name="exceptionMessage">The message that represents the exception thrown when the configuration error was detected.</param>
 public void LogInternalError(string policyName, string exceptionMessage)
 {
     if (WmiEnabled)
     {
         ManagementInstrumentation.Fire(new ExceptionHandlingFailureEvent(policyName, exceptionMessage));
     }
     if (EventLoggingEnabled)
     {
         string entryText = eventLogEntryFormatter.GetEntryText(exceptionMessage);
         EventLog.WriteEntry(GetEventSourceName(), entryText, EventLogEntryType.Error);
     }
 }
 /// <summary>
 /// Logs the occurrence of a configuration error for the Enterprise Library Logging Application Block through the
 /// available instrumentation mechanisms.
 /// </summary>
 /// <param name="exception">The exception raised for the configuration error.</param>
 public void LogConfigurationError(Exception exception)
 {
     if (WmiEnabled)
     {
         ManagementInstrumentation.Fire(new LoggingConfigurationFailureEvent(exception.Message));
     }
     if (EventLoggingEnabled)
     {
         string entryText = eventLogEntryFormatter.GetEntryText(Resources.ConfigurationFailureLogging, exception);
         EventLog.WriteEntry(GetEventSourceName(), entryText, EventLogEntryType.Error);
     }
 }
        public void FailureLoggingError(object sender, FailureLoggingErrorEventArgs e)
        {
            if (WmiEnabled)
            {
                ManagementInstrumentation.Fire(new LoggingFailureLoggingErrorEvent(e.ErrorMessage, e.Exception.ToString()));
            }
            if (EventLoggingEnabled)
            {
                string entryText = eventLogEntryFormatter.GetEntryText(e.ErrorMessage, e.Exception);

                EventLog.WriteEntry(GetEventSourceName(), entryText, EventLogEntryType.Error);
            }
        }
 /// <summary>
 /// Delivers the trace data as an event.
 /// </summary>
 /// <param name="eventCache">The context information provided by <see cref="System.Diagnostics"/>.</param>
 /// <param name="source">The name of the trace source that delivered the trace data.</param>
 /// <param name="eventType">The type of event.</param>
 /// <param name="id">The id of the event.</param>
 /// <param name="data">The data to trace.</param>
 public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
 {
     if (data is LogEntry)
     {
         ManagementInstrumentation.Fire(data as LogEntry);
         instrumentationProvider.FireTraceListenerEntryWrittenEvent();
     }
     else if (data is string)
     {
         Write(data);
     }
     else
     {
         base.TraceData(eventCache, source, eventType, id, data);
     }
 }
Esempio n. 9
0
 /// <summary>
 /// Logs the occurrence of a configuration error for the Enterprise Library Exception Handling Application Block through the
 /// available instrumentation mechanisms.
 /// </summary>
 /// <param name="exception">The exception raised for the configuration error.</param>
 /// <param name="policyName">The name of the Exception policy in which the configuration error was detected.</param>
 public void LogConfigurationError(Exception exception, string policyName)
 {
     if (WmiEnabled)
     {
         ManagementInstrumentation.Fire(new ExceptionHandlingConfigurationFailureEvent(policyName, exception.Message));
     }
     if (EventLoggingEnabled)
     {
         string eventLogMessage
             = string.Format(
                   Resources.Culture,
                   Resources.ConfigurationFailureCreatingPolicy,
                   policyName);
         string entryText = eventLogEntryFormatter.GetEntryText(eventLogMessage, exception);
         EventLog.WriteEntry(GetEventSourceName(), entryText, EventLogEntryType.Error);
     }
 }
Esempio n. 10
0
 /// <summary>
 /// Logs the occurrence of a configuration error for the Enterprise Library Data Access Application Block through the
 /// available instrumentation mechanisms.
 /// </summary>
 /// <param name="instanceName">Name of the <see cref="Database"/> instance in which the configuration error was detected.</param>
 /// <param name="exception">The exception raised for the configuration error.</param>
 public void LogConfigurationError(Exception exception, string instanceName)
 {
     if (WmiEnabled)
     {
         ManagementInstrumentation.Fire(new DataConfigurationFailureEvent(instanceName, exception.ToString()));
     }
     if (EventLoggingEnabled)
     {
         string eventLogMessage
             = string.Format(
                   Resources.Culture,
                   Resources.ConfigurationFailureCreatingDatabase,
                   instanceName);
         string entryText = eventLogEntryFormatter.GetEntryText(eventLogMessage, exception);
         EventLog.WriteEntry(GetEventSourceName(), entryText, EventLogEntryType.Error);
     }
 }
Esempio n. 11
0
 /// <summary>
 /// Delivers the trace data as an event.
 /// </summary>
 /// <param name="eventCache">The context information provided by <see cref="System.Diagnostics"/>.</param>
 /// <param name="source">The name of the trace source that delivered the trace data.</param>
 /// <param name="eventType">The type of event.</param>
 /// <param name="id">The id of the event.</param>
 /// <param name="data">The data to trace.</param>
 public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
 {
     if ((this.Filter == null) || this.Filter.ShouldTrace(eventCache, source, eventType, id, null, null, data, null))
     {
         if (data is LogEntry)
         {
             ManagementInstrumentation.Fire(data as LogEntry);
         }
         else if (data is string)
         {
             Write(data);
         }
         else
         {
             base.TraceData(eventCache, source, eventType, id, data);
         }
     }
 }
Esempio n. 12
0
        public void CyptographicOperationFailed(object sender, CrytographicOperationErrorEventArgs e)
        {
            if (EventLoggingEnabled)
            {
                string errorMessage
                    = string.Format(
                          Resources.Culture,
                          Resources.ErrorCryptographicOperationFailed,
                          instanceName);
                string entryText = new EventLogEntryFormatter(Resources.BlockName).GetEntryText(errorMessage, e.Exception, e.Message);

                EventLog.WriteEntry(GetEventSourceName(), entryText, EventLogEntryType.Error);
            }
            if (WmiEnabled)
            {
                ManagementInstrumentation.Fire(new HashOperationFailedEvent(instanceName, e.Message, e.Exception.ToString()));
            }
        }
        /// <summary>
        /// Logs the occurrence of a configuration error for the Enterprise Library Security Application Block through the
        /// available instrumentation mechanisms.
        /// </summary>
        /// <param name="instanceName">The name of the instance this errors applies to.</param>
        /// <param name="messageTemplate">The format of the message that describes the error, with as parameter ({0}) the <paramref name="instanceName"/>.</param>
        /// <param name="exception">The exception raised for the configuration error.</param>
        /// <exception cref="FormatException"><paramref name="messageTemplate"/> could not be formatted by <see cref="String.Format(System.IFormatProvider, string, object[])"/> given the parameter <paramref name="instanceName"/>.</exception>
        public void LogConfigurationError(string instanceName, string messageTemplate, Exception exception)
        {
            if (WmiEnabled)
            {
                ManagementInstrumentation.Fire(new SecurityConfigurationFailureEvent(instanceName, exception.ToString()));
            }
            if (EventLoggingEnabled)
            {
                string errorMessage
                    = string.Format(
                          Resources.Culture,
                          messageTemplate,
                          instanceName);
                string entryText = eventLogEntryFormatter.GetEntryText(errorMessage, exception);

                EventLog.WriteEntry(GetEventSourceName(), entryText, EventLogEntryType.Error);
            }
        }
Esempio n. 14
0
        public void ExceptionHandlingErrorOccurred(object sender, ExceptionHandlingErrorEventArgs e)
        {
            if (EventLoggingEnabled)
            {
                string errorMessage
                    = string.Format(
                          Resources.Culture,
                          Resources.ErrorHandlingExceptionMessage,
                          instanceName);
                string entryText = new EventLogEntryFormatter(Resources.BlockName).GetEntryText(errorMessage, e.Message);

                EventLog.WriteEntry(GetEventSourceName(), entryText, EventLogEntryType.Error);
            }
            if (WmiEnabled)
            {
                ManagementInstrumentation.Fire(new ExceptionHandlingFailureEvent(instanceName, e.Message));
            }
        }
		/// <summary>
		/// Raises a Wmi event.
		/// </summary>
		/// <remarks>
		/// This method's is necessary to run instrumentation in partial trust. Since assembly System.Management 
		/// does not allow partially trusted callers, referencing class ManagementInstrumentation from the 
		/// instrumentation handlers makes the delegates fail because of the implicit LinkDemands, even when
		/// Wmi instrumentation is disabled.
		/// </remarks>
		/// <param name="wmiEvent">The Wmi event to raise</param>
		protected void FireManagementInstrumentation(BaseWmiEvent wmiEvent)
		{
			ManagementInstrumentation.Fire(wmiEvent);
		}