How to use E2E that can be viewed in SvcTraceViewer?

Topics: Enterprise Library Core, General discussion, Logging Application Block
Apr 16, 2007 at 1:23 PM
What do I need to do / config that my logs are valueable to read in SvcTraceViewer.

It seems that the Tracer class in entlib doesn't trigger TraceSource.TraceTransfer() method so that the graph in SvcTraceViewer won't show up.
Apr 13, 2008 at 7:23 AM
Sadly it's not implemented in the EntLib (I am writing a wrapper for Tracer() to fix that). I managed to do it like this:

Guid _oldActivityID = System.Diagnostics.Trace.CorrelationManager.ActivityId;
Guid _newActivityID = Guid.NewGuid();
Logger.SetContextItem("Parameter: name", name);
Logger.Write(new LogEntry() { Severity = TraceEventType.Transfer, RelatedActivityId = _newActivityID });
System.Diagnostics.Trace.CorrelationManager.ActivityId = _newActivityID;
using (new Tracer(General.TraceCategory.Service)) {
Logger.Write(String.Format("Service-Call to Service_AddItem '{0}'", name));
//do your stuff here
Logger.Write(new LogEntry() { Severity = TraceEventType.Transfer, RelatedActivityId = _oldActivityID });
} //tracer
System.Diagnostics.Trace.CorrelationManager.ActivityId = _oldActivityID;

see also http://msdn2.microsoft.com/en-us/library/aa738759.aspx

regards, Tilli