C# Class NLog.NLogTraceListener

TraceListener which routes all messages through NLog.
Inheritance: System.Diagnostics.TraceListener
Show file Open project: NLog/NLog Class Usage Examples

Public Methods

Method Description
Close ( ) : void

When overridden in a derived class, closes the output stream so it no longer receives tracing or debugging output.

Fail ( string message ) : void

Emits an error message.

Fail ( string message, string detailMessage ) : void

Emits an error message and a detailed error message.

Flush ( ) : void

Flushes the output (if DisableFlush is not true) buffer with the default timeout of 15 seconds.

NLogTraceListener ( ) : System

Initializes a new instance of the NLogTraceListener class.

TraceData ( TraceEventCache eventCache, string source, TraceEventType eventType, int id ) : void

Writes trace information, an array of data objects and event information to the listener specific output.

TraceData ( TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data ) : void

Writes trace information, a data object and event information to the listener specific output.

TraceEvent ( TraceEventCache eventCache, string source, TraceEventType eventType, int id ) : void

Writes trace and event information to the listener specific output.

TraceEvent ( TraceEventCache eventCache, string source, TraceEventType eventType, int id, string format ) : void

Writes trace information, a formatted array of objects and event information to the listener specific output.

TraceTransfer ( TraceEventCache eventCache, string source, int id, string message, Guid relatedActivityId ) : void

Writes trace information, a message, a related activity identity and event information to the listener specific output.

Write ( string message ) : void

When overridden in a derived class, writes the specified message to the listener you create in the derived class.

WriteLine ( string message ) : void

When overridden in a derived class, writes a message to the listener you create in the derived class, followed by a line terminator.

Protected Methods

Method Description
GetSupportedAttributes ( ) : string[]

Gets the custom attributes supported by the trace listener.

ProcessLogEventInfo ( LogLevel logLevel, string loggerName, [ message, object arguments, int eventId, TraceEventType eventType, Guid relatedActiviyId ) : void

Process the log event The log level. The name of the logger. The log message. The log parameters. The event id. The event type. The related activity id.

Private Methods

Method Description
InitAttributes ( ) : void
TranslateLogLevel ( TraceEventType eventType ) : LogLevel

Translates the event type to level from TraceEventType.

Method Details

Close() public method

When overridden in a derived class, closes the output stream so it no longer receives tracing or debugging output.
public Close ( ) : void
return void

Fail() public method

Emits an error message.
public Fail ( string message ) : void
message string A message to emit.
return void

Fail() public method

Emits an error message and a detailed error message.
public Fail ( string message, string detailMessage ) : void
message string A message to emit.
detailMessage string A detailed message to emit.
return void

Flush() public method

Flushes the output (if DisableFlush is not true) buffer with the default timeout of 15 seconds.
public Flush ( ) : void
return void

GetSupportedAttributes() protected method

Gets the custom attributes supported by the trace listener.
protected GetSupportedAttributes ( ) : string[]
return string[]

NLogTraceListener() public method

Initializes a new instance of the NLogTraceListener class.
public NLogTraceListener ( ) : System
return System

ProcessLogEventInfo() protected method

Process the log event The log level. The name of the logger. The log message. The log parameters. The event id. The event type. The related activity id.
protected ProcessLogEventInfo ( LogLevel logLevel, string loggerName, [ message, object arguments, int eventId, TraceEventType eventType, Guid relatedActiviyId ) : void
logLevel LogLevel
loggerName string
message [
arguments object
eventId int
eventType TraceEventType
relatedActiviyId Guid
return void

TraceData() public method

Writes trace information, an array of data objects and event information to the listener specific output.
public TraceData ( TraceEventCache eventCache, string source, TraceEventType eventType, int id ) : void
eventCache TraceEventCache A object that contains the current process ID, thread ID, and stack trace information.
source string A name used to identify the output, typically the name of the application that generated the trace event.
eventType TraceEventType One of the values specifying the type of event that has caused the trace.
id int A numeric identifier for the event.
return void

TraceData() public method

Writes trace information, a data object and event information to the listener specific output.
public TraceData ( TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data ) : void
eventCache TraceEventCache A object that contains the current process ID, thread ID, and stack trace information.
source string A name used to identify the output, typically the name of the application that generated the trace event.
eventType TraceEventType One of the values specifying the type of event that has caused the trace.
id int A numeric identifier for the event.
data object The trace data to emit.
return void

TraceEvent() public method

Writes trace and event information to the listener specific output.
public TraceEvent ( TraceEventCache eventCache, string source, TraceEventType eventType, int id ) : void
eventCache TraceEventCache A object that contains the current process ID, thread ID, and stack trace information.
source string A name used to identify the output, typically the name of the application that generated the trace event.
eventType TraceEventType One of the values specifying the type of event that has caused the trace.
id int A numeric identifier for the event.
return void

TraceEvent() public method

Writes trace information, a formatted array of objects and event information to the listener specific output.
public TraceEvent ( TraceEventCache eventCache, string source, TraceEventType eventType, int id, string format ) : void
eventCache TraceEventCache A object that contains the current process ID, thread ID, and stack trace information.
source string A name used to identify the output, typically the name of the application that generated the trace event.
eventType TraceEventType One of the values specifying the type of event that has caused the trace.
id int A numeric identifier for the event.
format string A format string that contains zero or more format items, which correspond to objects in the array.
return void

TraceTransfer() public method

Writes trace information, a message, a related activity identity and event information to the listener specific output.
public TraceTransfer ( TraceEventCache eventCache, string source, int id, string message, Guid relatedActivityId ) : void
eventCache TraceEventCache A object that contains the current process ID, thread ID, and stack trace information.
source string A name used to identify the output, typically the name of the application that generated the trace event.
id int A numeric identifier for the event.
message string A message to write.
relatedActivityId Guid A object identifying a related activity.
return void

Write() public method

When overridden in a derived class, writes the specified message to the listener you create in the derived class.
public Write ( string message ) : void
message string A message to write.
return void

WriteLine() public method

When overridden in a derived class, writes a message to the listener you create in the derived class, followed by a line terminator.
public WriteLine ( string message ) : void
message string A message to write.
return void