[TestMethod] public void TestTrace() { TraceSource wcfTrace = new TraceSource("System.ServiceModel"); Guid currentActivity = Trace.CorrelationManager.ActivityId; Guid newActivity = Guid.NewGuid(); Guid newActivity2 = Guid.NewGuid(); Guid newActivity3 = Guid.NewGuid(); wcfTrace.TraceEvent(TraceEventType.Start, 100, "[+] Method entered"); wcfTrace.TraceEvent(TraceEventType.Information, 101, "[+] In current activity"); wcfTrace.TraceEvent(TraceEventType.Start, 100, "[+] Still in current activity"); wcfTrace.TraceEvent(TraceEventType.Information, 102, "[+] Still in current activity"); wcfTrace.TraceTransfer(0, "[+] Start Level 1 activity", newActivity); Trace.CorrelationManager.ActivityId = newActivity; wcfTrace.TraceEvent(TraceEventType.Information, 103, "[+] Hello from Level 1"); wcfTrace.TraceEvent(TraceEventType.Warning, 104, "[+] Level 1"); wcfTrace.TraceEvent(TraceEventType.Error, 103, "[+] Level 1"); wcfTrace.TraceEvent(TraceEventType.Critical, 105, "[+] Level 1"); wcfTrace.TraceTransfer(0, "[+] Start Level 2 activity",newActivity2); Trace.CorrelationManager.ActivityId = newActivity2; wcfTrace.TraceEvent(TraceEventType.Information, 102, "[+] Hello from Level 2"); wcfTrace.TraceEvent(TraceEventType.Information, 103, "[+] Level 2"); wcfTrace.TraceTransfer(0, "[+] Jump back to level 1", newActivity); Trace.CorrelationManager.ActivityId = newActivity; wcfTrace.TraceEvent(TraceEventType.Transfer, 101, "[+] Hello from Level 1"); wcfTrace.TraceEvent(TraceEventType.Information, 102, "[+] Level 1"); wcfTrace.TraceTransfer(0, "[+] Jump back to current", currentActivity); Trace.CorrelationManager.ActivityId = currentActivity; wcfTrace.TraceEvent(TraceEventType.Information, 103, "[+] Again in current activity"); wcfTrace.TraceEvent(TraceEventType.Stop, 101, "[+] Method exited"); } |