Class AsynchronousTraceListenerWrapper
- Assembly
- Microsoft.Practices.EnterpriseLibrary.Logging.dll
Trace listener that wraps a normal trace listener to perform asynchronous tracing requests.
public sealed class AsynchronousTraceListenerWrapper : TraceListener, IDisposable, IAsynchronousTraceListener
- Inheritance
-
AsynchronousTraceListenerWrapper
- Implements
- Inherited Members
Remarks
When disposed, the wrapper will attempt to complete all buffered tracing requests before completing the dispose request. To change this behavior specify a value for the disposeTimeout constructor parameter other than null or InfiniteTimeSpan.
Constructors
AsynchronousTraceListenerWrapper(TraceListener, bool, int?, int?, TimeSpan?)
Initializes a new instance of the AsynchronousTraceListenerWrapper class.
public AsynchronousTraceListenerWrapper(TraceListener wrappedTraceListener, bool ownsWrappedTraceListener = true, int? bufferSize = 30000, int? maxDegreeOfParallelism = null, TimeSpan? disposeTimeout = null)
Parameters
wrappedTraceListener
TraceListenerThe wrapped trace listener.
ownsWrappedTraceListener
boolIndicates whether the wrapper should dispose the wrapped trace listener.
bufferSize
int?Size of the buffer for asynchronous requests.
maxDegreeOfParallelism
int?The max degree of parallelism for thread safe listeners. Specify null to use the current core count.
disposeTimeout
TimeSpan?The timeout for waiting to complete buffered requests when disposing. When null the default of InfiniteTimeSpan is used.
Properties
TraceListener
Gets the wrapped TraceListener.
public TraceListener TraceListener { get; }
Property Value
Methods
Close()
When overridden in a derived class, closes the output stream so it no longer receives tracing or debugging output.
public override void Close()
Dispose(bool)
Releases the unmanaged resources used by the TraceListener and optionally releases the managed resources.
protected override void Dispose(bool disposing)
Parameters
disposing
booltrue to release both managed and unmanaged resources; false to release only unmanaged resources.
Fail(string)
Emits an error message to the listener you create when you implement the TraceListener class.
public override void Fail(string message)
Parameters
message
stringA message to emit.
Fail(string, string)
Emits an error message and a detailed error message to the listener you create when you implement the TraceListener class.
public override void Fail(string message, string detailMessage)
Parameters
Flush()
When overridden in a derived class, flushes the output buffer.
public override void Flush()
Flush(ReportTracingError)
Flushes the output buffer asynchronously.
public void Flush(ReportTracingError reportError)
Parameters
reportError
ReportTracingErrorThe delegate to use to report errors while tracing asynchronously.
TraceData(TraceEventCache, string, TraceEventType, int, object)
Writes trace information, a data object and event information to the listener specific output.
public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
Parameters
eventCache
TraceEventCacheA TraceEventCache object that contains the current process ID, thread ID, and stack trace information.
source
stringA name used to identify the output, typically the name of the application that generated the trace event.
eventType
TraceEventTypeOne of the TraceEventType values specifying the type of event that has caused the trace.
id
intA numeric identifier for the event.
data
objectThe trace data to emit.
TraceData(TraceEventCache, string, TraceEventType, int, object, ReportTracingError)
Writes trace information, a data object and event information to the listener specific output.
public void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data, ReportTracingError reportError)
Parameters
eventCache
TraceEventCacheA TraceEventCache object that contains the current process ID, thread ID, and stack trace information.
source
stringA name used to identify the output, typically the name of the application that generated the trace event.
eventType
TraceEventTypeOne of the TraceEventType values specifying the type of event that has caused the trace.
id
intA numeric identifier for the event.
data
objectThe trace data to emit.
reportError
ReportTracingErrorThe delegate to use to report errors while tracing asynchronously.
TraceData(TraceEventCache, string, TraceEventType, int, params object[])
Writes trace information, an array of data objects and event information to the listener specific output.
public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, params object[] data)
Parameters
eventCache
TraceEventCacheA TraceEventCache object that contains the current process ID, thread ID, and stack trace information.
source
stringA name used to identify the output, typically the name of the application that generated the trace event.
eventType
TraceEventTypeOne of the TraceEventType values specifying the type of event that has caused the trace.
id
intA numeric identifier for the event.
data
object[]An array of objects to emit as data.
TraceEvent(TraceEventCache, string, TraceEventType, int)
Writes trace and event information to the listener specific output.
public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id)
Parameters
eventCache
TraceEventCacheA TraceEventCache object that contains the current process ID, thread ID, and stack trace information.
source
stringA name used to identify the output, typically the name of the application that generated the trace event.
eventType
TraceEventTypeOne of the TraceEventType values specifying the type of event that has caused the trace.
id
intA numeric identifier for the event.
TraceEvent(TraceEventCache, string, TraceEventType, int, string)
Writes trace information, a message, and event information to the listener specific output.
public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string message)
Parameters
eventCache
TraceEventCacheA TraceEventCache object that contains the current process ID, thread ID, and stack trace information.
source
stringA name used to identify the output, typically the name of the application that generated the trace event.
eventType
TraceEventTypeOne of the TraceEventType values specifying the type of event that has caused the trace.
id
intA numeric identifier for the event.
message
stringA message to write.
TraceEvent(TraceEventCache, string, TraceEventType, int, string, params object[])
Writes trace information, a formatted array of objects and event information to the listener specific output.
public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string format, params object[] args)
Parameters
eventCache
TraceEventCacheA TraceEventCache object that contains the current process ID, thread ID, and stack trace information.
source
stringA name used to identify the output, typically the name of the application that generated the trace event.
eventType
TraceEventTypeOne of the TraceEventType values specifying the type of event that has caused the trace.
id
intA numeric identifier for the event.
format
stringA format string that contains zero or more format items, which correspond to objects in the
args
array.args
object[]An object array containing zero or more objects to format.
TraceTransfer(TraceEventCache, string, int, string, Guid)
Writes trace information, a message, a related activity identity and event information to the listener specific output.
public override void TraceTransfer(TraceEventCache eventCache, string source, int id, string message, Guid relatedActivityId)
Parameters
eventCache
TraceEventCacheA TraceEventCache object that contains the current process ID, thread ID, and stack trace information.
source
stringA name used to identify the output, typically the name of the application that generated the trace event.
id
intA numeric identifier for the event.
message
stringA message to write.
relatedActivityId
GuidA Guid object identifying a related activity.
TraceTransfer(TraceEventCache, string, int, string, Guid, ReportTracingError)
Writes trace information, a message, a related activity identity and event information to the listener specific output.
public void TraceTransfer(TraceEventCache eventCache, string source, int id, string message, Guid relatedActivityId, ReportTracingError reportError)
Parameters
eventCache
TraceEventCacheA TraceEventCache object that contains the current process ID, thread ID, and stack trace information.
source
stringA name used to identify the output, typically the name of the application that generated the trace event.
id
intA numeric identifier for the event.
message
stringA message to write.
relatedActivityId
GuidA Guid object identifying a related activity.
reportError
ReportTracingErrorThe delegate to use to report errors while tracing asynchronously.
Write(object)
Writes the value of the object's ToString() method to the listener you create when you implement the TraceListener class.
public override void Write(object o)
Parameters
Write(object, string)
Writes a category name and the value of the object's ToString() method to the listener you create when you implement the TraceListener class.
public override void Write(object o, string category)
Parameters
o
objectAn object whose fully qualified class name you want to write.
category
stringA category name used to organize the output.
Write(string)
When overridden in a derived class, writes the specified message to the listener you create in the derived class.
public override void Write(string message)
Parameters
message
stringA message to write.
Exceptions
Write(string, string)
Writes a category name and a message to the listener you create when you implement the TraceListener class.
public override void Write(string message, string category)
Parameters
WriteLine(object)
Writes the value of the object's ToString() method to the listener you create when you implement the TraceListener class, followed by a line terminator.
public override void WriteLine(object o)
Parameters
WriteLine(object, string)
Writes a category name and the value of the object's ToString() method to the listener you create when you implement the TraceListener class, followed by a line terminator.
public override void WriteLine(object o, string category)
Parameters
o
objectAn object whose fully qualified class name you want to write.
category
stringA category name used to organize the output.
WriteLine(string)
When overridden in a derived class, writes a message to the listener you create in the derived class, followed by a line terminator.
public override void WriteLine(string message)
Parameters
message
stringA message to write.
Exceptions
WriteLine(string, string)
Writes a category name and a message to the listener you create when you implement the TraceListener class, followed by a line terminator.
public override void WriteLine(string message, string category)