Class Tracer
- Namespace
- Microsoft.Practices.EnterpriseLibrary.Logging
- Assembly
- Microsoft.Practices.EnterpriseLibrary.Logging.dll
Represents a performance tracing class to log method entry/exit and duration.
public class Tracer : IDisposable
- Inheritance
-
Tracer
- Implements
- Inherited Members
Remarks
Lifetime of the Tracer object will determine the beginning and the end of the trace. The trace message will include, method being traced, start time, end time and duration.
Since Tracer uses the Logging Application Block to log the trace message, you can include application data as part of your trace message. Configured items from call context will be logged as part of the message.
Trace message will be logged to the log category with the same name as the tracer operation name. You must configure the operation categories, or the catch-all categories, with desired log sinks to log the trace messages.
Constructors
Tracer(string)
Initializes a new instance of the Tracer class with the given logical operation name.
public Tracer(string operation)
Parameters
Remarks
If an existing activity id is already set, it will be kept. Otherwise, a new activity id will be created.
Tracer(string, LogWriter)
Initializes a new instance of the Tracer class with the given logical operation name and activity id.
public Tracer(string operation, LogWriter writer)
Parameters
operation
stringThe operation for the Tracer.
writer
LogWriterThe LogWriter that is used to write trace messages.
Remarks
If an existing activity id is already set, it will be kept. Otherwise, a new activity id will be created.
Exceptions
- ArgumentNullException
writer
is null.
Tracer(string, Guid)
Initializes a new instance of the Tracer class with the given logical operation name and activity id.
public Tracer(string operation, Guid activityId)
Parameters
Remarks
The activity id will override a previous activity id.
Tracer(string, Guid, LogWriter)
Initializes a new instance of the Tracer class with the given logical operation name and activity id.
public Tracer(string operation, Guid activityId, LogWriter writer)
Parameters
operation
stringThe operation for the Tracer.
activityId
GuidThe activity id.
writer
LogWriterThe LogWriter that is used to write trace messages.
Remarks
The activity id will override a previous activity id.
Exceptions
- ArgumentNullException
writer
is null.
Fields
ActivityIdPropertyKey
Name of the entry in the ExtendedProperties having the activity id
public const string ActivityIdPropertyKey = "TracerActivityId"
Field Value
endTitle
Title for operation end Trace messages
public const string endTitle = "TracerExit"
Field Value
eventId
Event id for Trace messages
public const int eventId = 1
Field Value
priority
Priority value for Trace messages
public const int priority = 5
Field Value
startTitle
Title for operation start Trace messages
public const string startTitle = "TracerEnter"
Field Value
Methods
Dispose()
Causes the Tracer to output its closing message.
public void Dispose()
Dispose(bool)
Releases unmanaged and - optionally - managed resources.
protected virtual void Dispose(bool disposing)
Parameters
disposing
booltrue
to release both managed and unmanaged resources;false
to release only unmanaged resources.
IsTracingEnabled()
Indicates whether tracing is enabled
public bool IsTracingEnabled()