internal Exception ThrowHelper(Exception exception, TraceEventType eventType, TraceRecord extendedData) { bool flag = (this.diagnosticTrace != null) && this.diagnosticTrace.ShouldTrace(eventType); if (flag) { using (useStaticActivityId ? Activity.CreateActivity(activityId) : null) { this.diagnosticTrace.TraceEvent(eventType, 0x20003, System.ServiceModel.Diagnostics.DiagnosticTrace.GenerateMsdnTraceCode("System.ServiceModel.Diagnostics", "ThrowingException"), TraceSR.GetString("ThrowingException"), extendedData, exception, null); } } string str = flag ? exception.StackTrace : null; if (!string.IsNullOrEmpty(str)) { IDictionary data = exception.Data; if (((data != null) && !data.IsReadOnly) && !data.IsFixedSize) { object obj2 = data["System.ServiceModel.Diagnostics.ExceptionUtility.ExceptionStackAsString"]; string str2 = (obj2 == null) ? "" : (obj2 as string); if (str2 != null) { str2 = str2 + ((str2.Length == 0) ? "" : Environment.NewLine) + "throw" + Environment.NewLine + str + Environment.NewLine + "catch" + Environment.NewLine; data["System.ServiceModel.Diagnostics.ExceptionUtility.ExceptionStackAsString"] = str2; } } } return exception; }
internal static void Trace(TraceEventType severity, int traceCode, string traceDescription, TraceRecord extendedData, object source, Guid activityId, Exception exception) { if (DiagnosticUtility.ShouldTrace(severity)) { string msdnTraceCode = System.ServiceModel.Diagnostics.DiagnosticTrace.GenerateMsdnTraceCode("Microsoft.Transactions.TransactionBridge", traceCodes[traceCode]); DiagnosticUtility.DiagnosticTrace.TraceEvent(severity, traceCode, msdnTraceCode, traceDescription, extendedData, exception, activityId, source); } }
internal static void Trace(TraceEventType severity, int traceCode, string traceDescription, TraceRecord record, Exception exception) { Fx.Assert(traceCodes.ContainsKey(traceCode), string.Format(CultureInfo.InvariantCulture, "Unsupported trace code: Please add trace code 0x{0} to the dictionary TraceUtility.traceCodes in {1}", traceCode.ToString("X", CultureInfo.InvariantCulture), typeof(TraceUtility))); string msdnTraceCode = System.ServiceModel.Diagnostics.LegacyDiagnosticTrace.GenerateMsdnTraceCode("System.Runtime.Serialization", traceCodes[traceCode]); DiagnosticUtility.DiagnosticTrace.TraceEvent(severity, traceCode, msdnTraceCode, traceDescription, record, exception, null); }
internal static void TraceEvent(TraceEventType severity, int traceCode, string traceDescription, TraceRecord extendedData, object source, Exception exception) { if (DiagnosticUtility.ShouldTrace(severity)) { Guid activityId = System.Runtime.Diagnostics.DiagnosticTrace.ActivityId; string msdnTraceCode = System.ServiceModel.Diagnostics.DiagnosticTrace.GenerateMsdnTraceCode("System.IdentityModel", traceCodes[traceCode]); DiagnosticUtility.DiagnosticTrace.TraceEvent(severity, traceCode, msdnTraceCode, traceDescription, extendedData, exception, activityId, source); } }
internal static void TraceEvent(TraceEventType severity, int traceCode, string traceDescription, TraceRecord record, object source, Exception exception) { if (DiagnosticUtility.ShouldTrace(severity)) { Fx.Assert(traceCodes.ContainsKey(traceCode), string.Format(CultureInfo.InvariantCulture, "Unsupported trace code: Please add trace code 0x{0} to the dictionary ListenerTraceUtility.traceCodes in {1}", traceCode.ToString("X", CultureInfo.InvariantCulture), typeof(ListenerTraceUtility))); string msdnTraceCode = LegacyDiagnosticTrace.GenerateMsdnTraceCode("SMSvcHost", traceCodes[traceCode]); DiagnosticUtility.DiagnosticTrace.TraceEvent(severity, traceCode, msdnTraceCode, traceDescription, record, exception, source); } }
internal static void TraceEvent( TraceEventType severity, int traceCode, string traceDescription, TraceRecord extendedData, object source, Exception exception ) { if ( DiagnosticUtility.ShouldTrace( severity ) ) { Guid activityId = DiagnosticTraceBase.ActivityId; Fx.Assert( traceCodes.ContainsKey( traceCode ), string.Format( CultureInfo.InvariantCulture, "Unsupported trace code: Please add trace code 0x{0} to the dictionary TraceUtility.traceCodes in {1}", traceCode.ToString( "X", CultureInfo.InvariantCulture ), typeof( TraceUtility ) ) ); string msdnTraceCode = System.ServiceModel.Diagnostics.LegacyDiagnosticTrace.GenerateMsdnTraceCode( "System.IdentityModel", traceCodes[traceCode]); DiagnosticUtility.DiagnosticTrace.TraceEvent( severity, traceCode, msdnTraceCode, traceDescription, extendedData, exception, activityId, source ); } }
internal static void TraceEvent(TraceEventType severity, int traceCode, string traceDescription, TraceRecord record, object source, Exception exception) { string msdnTraceCode = System.ServiceModel.Diagnostics.DiagnosticTrace.GenerateMsdnTraceCode("System.ServiceModel.Activation", traceCodes[traceCode]); DiagnosticUtility.DiagnosticTrace.TraceEvent(severity, traceCode, msdnTraceCode, traceDescription, record, exception, source); }
public override void TraceEventLogEvent(TraceEventType type, TraceRecord traceRecord) { TraceEvent(type, DiagnosticsTraceCode.EventLog, LegacyDiagnosticTrace.GenerateMsdnTraceCode("System.ServiceModel.Diagnostics", "EventLog"), TraceSR.GetString(TraceSR.TraceCodeEventLog), traceRecord, null, null); }
internal static void SuspendSignpostEvent(TraceRecord traceRecord) { TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, traceRecord, null); if (IsEtwEventEnabled(0x16)) { WriteEtwEvent(0x16, payload.ExtendedData, payload.AppDomainFriendlyName); } }
internal static void Trace(TraceEventType severity, int traceCode, string traceDescription, TraceRecord record) { Trace(severity, traceCode, traceDescription, record, null); }
/// <summary> /// Gets trace definition like: Wrote to the EventLog. /// Event description ID=57403, Level=warning, Channel=Debug /// </summary> /// <param name="trace">The trace provider</param> /// <param name="traceRecord">Extended data (TraceRecord) for the event</param> internal static void TraceCodeEventLogWarning(EtwDiagnosticTrace trace, TraceRecord traceRecord) { WcfEventSource.Instance.TraceCodeEventLogWarning(traceRecord.EventId); }
internal static void SuspendSignpostEvent(TraceRecord traceRecord) { /* INTENTIONAL */ }
/// <summary> /// Gets trace definition like: Wrote to the EventLog. /// Event description ID=57402, Level=verbose, Channel=Debug /// </summary> /// <param name="trace">The trace provider</param> /// <param name="traceRecord">Extended data (TraceRecord) for the event</param> internal static void TraceCodeEventLogVerbose(EtwDiagnosticTrace trace, TraceRecord traceRecord) { }
/// <summary> /// Gets trace definition like: Wrote to the EventLog. /// Event description ID=57400, Level=error, Channel=Debug /// </summary> /// <param name="trace">The trace provider</param> /// <param name="traceRecord">Extended data (TraceRecord) for the event</param> internal static void TraceCodeEventLogError(EtwDiagnosticTrace trace, TraceRecord traceRecord) { }
/// <summary> /// Gets trace definition like: Wrote to the EventLog. /// Event description ID=57399, Level=critical, Channel=Debug /// </summary> /// <param name="trace">The trace provider</param> /// <param name="traceRecord">Extended data (TraceRecord) for the event</param> internal static void TraceCodeEventLogCritical(EtwDiagnosticTrace trace, TraceRecord traceRecord) { }
public TracePayload GetSerializedPayload(object source, TraceRecord traceRecord, Exception exception, bool getServiceReference) { throw ExceptionHelper.PlatformNotSupported(); }
/// <summary> /// Gets trace definition like: Activity boundary. /// Event description ID=441, Level=informational, Channel=Analytic /// </summary> /// <param name="traceRecord">Extended data (TraceRecord) for the event</param> internal static void StopSignpostEvent(TraceRecord traceRecord) { TracePayload payload = FxTrace.Trace.GetSerializedPayload(null, traceRecord, null); if (TD.IsEtwEventEnabled(6)) { TD.WriteEtwEvent(6, null, payload.ExtendedData, payload.AppDomainFriendlyName); } if (FxTrace.ShouldTraceInformationToTraceSource) { string description = string.Format(Culture, ResourceManager.GetString("StopSignpostEvent", Culture)); TD.WriteTraceSource(6, description, payload); } }
internal static void TraceCodeEventLogInfo(DiagnosticTrace trace, TraceRecord traceRecord) { TracePayload payload = trace.GetSerializedPayload(null, traceRecord, null); if (IsEtwEventEnabled(trace, 8)) { WriteEtwEvent(trace, 8, payload.ExtendedData, payload.AppDomainFriendlyName); } if (trace.ShouldTraceToTraceSource(TraceEventLevel.Informational)) { string description = string.Format(Culture, ResourceManager.GetString("TraceCodeEventLogInfo", Culture), new object[0]); WriteTraceSource(trace, 8, description, payload); } }
internal static void ResumeSignpostEvent(TraceRecord traceRecord) { /* INTENTIONAL */ }
/// <summary> /// Gets trace definition like: Wrote to the EventLog. /// Event description ID=57403, Level=warning, Channel=Debug /// </summary> /// <param name="trace">The trace provider</param> /// <param name="traceRecord">Extended data (TraceRecord) for the event</param> internal static void TraceCodeEventLogWarning(EtwDiagnosticTrace trace, TraceRecord traceRecord) { }
/// <summary> /// Gets trace definition like: Wrote to the EventLog. /// Event description ID=57403, Level=warning, Channel=Debug /// </summary> /// <param name="trace">The trace provider</param> /// <param name="traceRecord">Extended data (TraceRecord) for the event</param> internal static void TraceCodeEventLogWarning(EtwDiagnosticTrace trace, TraceRecord traceRecord) { TracePayload payload = trace.GetSerializedPayload(null, traceRecord, null); if (TraceCore.IsEtwEventEnabled(trace, 9)) { TraceCore.WriteEtwEvent(trace, 9, null, payload.ExtendedData, payload.AppDomainFriendlyName); } if (trace.ShouldTraceToTraceSource(TraceEventLevel.Warning)) { string description = string.Format(Culture, ResourceManager.GetString("TraceCodeEventLogWarning", Culture)); TraceCore.WriteTraceSource(trace, 9, description, payload); } }
public abstract void TraceEventLogEvent(TraceEventType type, TraceRecord traceRecord);
internal Exception ThrowHelper(Exception exception, TraceEventType eventType, TraceRecord extendedData) { #pragma warning disable 618 bool shouldTrace = (this.diagnosticTrace != null && this.diagnosticTrace.ShouldTrace(eventType)); #pragma warning restore 618 if (shouldTrace) { using (ExceptionUtility.useStaticActivityId ? Activity.CreateActivity(ExceptionUtility.activityId) : null) { this.diagnosticTrace.TraceEvent(eventType, DiagnosticsTraceCode.ThrowingException, LegacyDiagnosticTrace.GenerateMsdnTraceCode("System.ServiceModel.Diagnostics", "ThrowingException"), TraceSR.GetString(TraceSR.ThrowingException), extendedData, exception, null); } IDictionary data = exception.Data; if (data != null && !data.IsReadOnly && !data.IsFixedSize) { object existingString = data[ExceptionStackAsStringKey]; string stackString = existingString == null ? "" : existingString as string; if (stackString != null) { string stack = exception.StackTrace; if (!string.IsNullOrEmpty(stack)) { stackString = string.Concat(stackString, stackString.Length == 0 ? "" : Environment.NewLine, "throw", Environment.NewLine, stack, Environment.NewLine, "catch", Environment.NewLine); data[ExceptionStackAsStringKey] = stackString; } } } } // Trace using ETW as well. exceptionTrace.TraceEtwException(exception, eventType); return exception; }
public TracePayload GetSerializedPayload(object source, TraceRecord traceRecord, Exception exception) { return this.GetSerializedPayload(source, traceRecord, exception, false); }
#pragma warning disable 56500 internal void TraceEvent(TraceEventType type, int code, string msdnTraceCode, string description, TraceRecord trace, Exception exception, object source) { #pragma warning disable 618 Fx.Assert(exception == null || type <= TraceEventType.Information, "Exceptions should be traced at Information or higher"); Fx.Assert(!string.IsNullOrEmpty(description), "All TraceCodes should have a description"); #pragma warning restore 618 TraceXPathNavigator navigator = null; try { #pragma warning disable 618 if (this.TraceSource != null && this.HaveListeners) #pragma warning restore 618 { try { BuildTrace(type, msdnTraceCode, description, trace, exception, source, out navigator); } catch (PlainXmlWriter.MaxSizeExceededException) { StringTraceRecord codeTraceRecord = new StringTraceRecord("TruncatedTraceId", msdnTraceCode); this.TraceEvent(type, DiagnosticsTraceCode.TraceTruncatedQuotaExceeded, LegacyDiagnosticTrace.GenerateMsdnTraceCode("System.ServiceModel.Diagnostics", "TraceTruncatedQuotaExceeded"), TraceSR.GetString(TraceSR.TraceCodeTraceTruncatedQuotaExceeded), codeTraceRecord, null, null); } this.TraceSource.TraceData(type, code, navigator); if (this.CalledShutdown) { this.TraceSource.Flush(); } // Must have been a successful trace. this.LastFailure = DateTime.MinValue; } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } LogTraceFailure(navigator == null ? string.Empty : navigator.ToString(), e); } }
public override void TraceEventLogEvent(TraceEventType type, TraceRecord traceRecord) { switch (type) { case TraceEventType.Critical: if (TraceCore.TraceCodeEventLogCriticalIsEnabled(this)) { TraceCore.TraceCodeEventLogCritical(this, traceRecord); } break; case TraceEventType.Verbose: if (TraceCore.TraceCodeEventLogVerboseIsEnabled(this)) { TraceCore.TraceCodeEventLogVerbose(this, traceRecord); } break; case TraceEventType.Information: if (TraceCore.TraceCodeEventLogInfoIsEnabled(this)) { TraceCore.TraceCodeEventLogInfo(this, traceRecord); } break; case TraceEventType.Warning: if (TraceCore.TraceCodeEventLogWarningIsEnabled(this)) { TraceCore.TraceCodeEventLogWarning(this, traceRecord); } break; case TraceEventType.Error: if (TraceCore.TraceCodeEventLogErrorIsEnabled(this)) { TraceCore.TraceCodeEventLogError(this, traceRecord); } break; } }
#pragma warning restore 56500 internal void TraceEvent(TraceEventType type, int code, string msdnTraceCode, string description, TraceRecord trace, Exception exception, Guid activityId, object source) { #pragma warning disable 618 using ((this.ShouldUseActivity && Guid.Empty != activityId) ? Activity.CreateActivity(activityId) : null) #pragma warning restore 618 { this.TraceEvent(type, code, msdnTraceCode, description, trace, exception, source); } }
public TracePayload GetSerializedPayload(object source, TraceRecord traceRecord, Exception exception, bool getServiceReference) { string eventSource = null; string extendedData = null; string serializedException = null; if (source != null) { eventSource = CreateSourceString(source); } if (traceRecord != null) { StringBuilder sb = StringBuilderPool.Take(); try { using (StringWriter stringWriter = new StringWriter(sb, CultureInfo.CurrentCulture)) { using (XmlTextWriter writer = new XmlTextWriter(stringWriter)) { writer.WriteStartElement(DiagnosticStrings.ExtendedDataTag); traceRecord.WriteTo(writer); writer.WriteEndElement(); writer.Flush(); stringWriter.Flush(); extendedData = sb.ToString(); } } } finally { StringBuilderPool.Return(sb); } } if (exception != null) { // We want to keep the ETW trace message to under 32k. So we keep the serialized exception to under 28k bytes. serializedException = ExceptionToTraceString(exception, MaxExceptionStringLength); } if (getServiceReference && (EtwDiagnosticTrace.traceAnnotation != null)) { return new TracePayload(serializedException, eventSource, DiagnosticTraceBase.AppDomainFriendlyName, extendedData, EtwDiagnosticTrace.traceAnnotation()); } return new TracePayload(serializedException, eventSource, DiagnosticTraceBase.AppDomainFriendlyName, extendedData, string.Empty); }
void BuildTrace(TraceEventType type, string msdnTraceCode, string description, TraceRecord trace, Exception exception, object source, out TraceXPathNavigator navigator) { PlainXmlWriter xmlWriter = new PlainXmlWriter(LegacyDiagnosticTrace.MaxTraceSize); navigator = xmlWriter.Navigator; this.BuildTrace(xmlWriter, type, msdnTraceCode, description, trace, exception, source); if (!ShouldLogPii) { navigator.RemovePii(DiagnosticStrings.HeadersPaths); } }
public TracePayload GetSerializedPayload(object source, TraceRecord traceRecord, Exception exception) { return(this.GetSerializedPayload(source, traceRecord, exception, false)); }
void BuildTrace(PlainXmlWriter xml, TraceEventType type, string msdnTraceCode, string description, TraceRecord trace, Exception exception, object source) { xml.WriteStartElement(DiagnosticStrings.TraceRecordTag); xml.WriteAttributeString(DiagnosticStrings.NamespaceTag, LegacyDiagnosticTrace.TraceRecordVersion); xml.WriteAttributeString(DiagnosticStrings.SeverityTag, DiagnosticTraceBase.LookupSeverity(type)); xml.WriteElementString(DiagnosticStrings.TraceCodeTag, msdnTraceCode); xml.WriteElementString(DiagnosticStrings.DescriptionTag, description); xml.WriteElementString(DiagnosticStrings.AppDomain, DiagnosticTraceBase.AppDomainFriendlyName); if (source != null) { xml.WriteElementString(DiagnosticStrings.SourceTag, CreateSourceString(source)); } if (trace != null) { xml.WriteStartElement(DiagnosticStrings.ExtendedDataTag); xml.WriteAttributeString(DiagnosticStrings.NamespaceTag, trace.EventId); trace.WriteTo(xml); xml.WriteEndElement(); } if (exception != null) { xml.WriteStartElement(DiagnosticStrings.ExceptionTag); AddExceptionToTraceString(xml, exception); xml.WriteEndElement(); } xml.WriteEndElement(); }