void Initialize() { if (!this.initialized) { lock (localSyncObject) { if (!this.initialized) { string attributeValue = this.Attributes[PiiTraceSource.LogPii]; bool shouldLogPii = false; if (!string.IsNullOrEmpty(attributeValue)) { if (!bool.TryParse(attributeValue, out shouldLogPii)) { shouldLogPii = false; } } if (shouldLogPii) { #pragma warning disable 618 System.Runtime.Diagnostics.EventLogger logger = new System.Runtime.Diagnostics.EventLogger(this.eventSourceName, null); #pragma warning restore 618 #if !NO_CONFIGURATION if (MachineSettingsSection.EnableLoggingKnownPii) #else if (false) #endif { logger.LogEvent(TraceEventType.Information, (ushort)System.Runtime.Diagnostics.EventLogCategory.MessageLogging, (uint)System.Runtime.Diagnostics.EventLogEventId.PiiLoggingOn, false); this.shouldLogPii = true; } else { logger.LogEvent(TraceEventType.Error, (ushort)System.Runtime.Diagnostics.EventLogCategory.MessageLogging, (uint)System.Runtime.Diagnostics.EventLogEventId.PiiLoggingNotAllowed, false); } } this.initialized = true; } } } }
internal LegacyDiagnosticTrace(TraceSourceKind sourceType, string traceSourceName, string eventSourceName) : base(traceSourceName) { this.traceSourceType = sourceType; this.EventSourceName = eventSourceName; try { this.CreateTraceSource(); this.AddDomainEventHandlersForCleanup(); } #if !NO_CONFIGURATION catch (ConfigurationErrorsException) { throw; } #endif catch (Exception e) { if (Fx.IsFatal(e)) { throw; } System.Runtime.Diagnostics.EventLogger logger = new System.Runtime.Diagnostics.EventLogger(this.EventSourceName, null); logger.LogEvent(TraceEventType.Error, (ushort)System.Runtime.Diagnostics.EventLogCategory.Tracing, (uint)System.Runtime.Diagnostics.EventLogEventId.FailedToSetupTracing, false, e.ToString()); } }
internal LegacyDiagnosticTrace(TraceSourceKind sourceType, string traceSourceName, string eventSourceName) : base(traceSourceName) { this.traceSourceType = sourceType; this.EventSourceName = eventSourceName; try { this.CreateTraceSource(); this.AddDomainEventHandlersForCleanup(); } catch (ConfigurationErrorsException) { throw; } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } System.Runtime.Diagnostics.EventLogger logger = new System.Runtime.Diagnostics.EventLogger(this.EventSourceName, null); logger.LogEvent(TraceEventType.Error, (ushort)System.Runtime.Diagnostics.EventLogCategory.Tracing, (uint)System.Runtime.Diagnostics.EventLogEventId.FailedToSetupTracing, false, e.ToString()); } }
public EtwDiagnosticTrace(string traceSourceName, Guid etwProviderId) : base(traceSourceName) { try { this.TraceSourceName = traceSourceName; this.EventSourceName = string.Concat(this.TraceSourceName, " ", EventSourceVersion); CreateTraceSource(); } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } #pragma warning disable 618 EventLogger logger = new EventLogger(this.EventSourceName, null); logger.LogEvent(TraceEventType.Error, TracingEventLogCategory, (uint)System.Runtime.Diagnostics.EventLogEventId.FailedToSetupTracing, false, exception.ToString()); #pragma warning restore 618 } try { CreateEtwProvider(etwProviderId); } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } this.etwProvider = null; #pragma warning disable 618 EventLogger logger = new EventLogger(this.EventSourceName, null); logger.LogEvent(TraceEventType.Error, TracingEventLogCategory, (uint)System.Runtime.Diagnostics.EventLogEventId.FailedToSetupTracing, false, exception.ToString()); #pragma warning restore 618 } if (this.TracingEnabled || this.EtwTracingEnabled) { #pragma warning disable 618 this.AddDomainEventHandlersForCleanup(); #pragma warning restore 618 } }
internal static void TraceFailFast(string message, System.Runtime.Diagnostics.EventLogger logger) { try { if (logger != null) { string stackTrace = null; try { stackTrace = new StackTrace().ToString(); } catch (Exception exception) { stackTrace = exception.Message; } finally { logger.LogEvent(TraceEventType.Critical, (ushort)EventLogCategory.FailFast, (uint)EventLogEventId.FailFast, message, stackTrace); } } } catch (Exception e) { if (logger != null) { logger.LogEvent(TraceEventType.Critical, (ushort)EventLogCategory.FailFast, (uint)EventLogEventId.FailFastException, e.ToString()); } throw; } }
public EtwDiagnosticTrace(string traceSourceName, Guid etwProviderId) : base(traceSourceName) { try { this.TraceSourceName = traceSourceName; base.EventSourceName = string.Concat(this.TraceSourceName, " ", "4.0.0.0"); this.CreateTraceSource(); } catch (Exception exception1) { Exception exception = exception1; if (!Fx.IsFatal(exception)) { EventLogger eventLogger = new EventLogger(base.EventSourceName, null); string[] str = new string[1]; str[0] = exception.ToString(); eventLogger.LogEvent(TraceEventType.Error, 4, -1073676188, false, str); } else { throw; } } try { this.CreateEtwProvider(etwProviderId); } catch (Exception exception3) { Exception exception2 = exception3; if (!Fx.IsFatal(exception2)) { this.etwProvider = null; EventLogger eventLogger1 = new EventLogger(base.EventSourceName, null); string[] strArrays = new string[1]; strArrays[0] = exception2.ToString(); eventLogger1.LogEvent(TraceEventType.Error, 4, -1073676188, false, strArrays); } else { throw; } } if (base.TracingEnabled || this.EtwTracingEnabled) { base.AddDomainEventHandlersForCleanup(); } }