DelimitedListTraceListener
Class
Definition
Directs tracing or debugging output to a text writer, such as a stream writer, or to a stream, such as a file stream.
public class DelimitedListTraceListener : System.Diagnostics.TextWriterTraceListener
- Inheritance
Inherited Members
System.Diagnostics.TextWriterTraceListener
System.Diagnostics.TraceListener
System.MarshalByRefObject
System.Object
Remarks
The trace output is in a delimited text format that uses the delimiter specified by the Delimiter property. The delimiter is used to terminate each field in a line of output. For example, to display the trace output in a Microsoft Excel spreadsheet, you might specify a comma (",") as a delimiter and create a comma-separated value (CSV) file.
Important
IDisposable interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its Dispose method in atry/catch block. To dispose of it indirectly, use a language construct such as using (in C#) or Using (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the IDisposable interface topic.
You can enable or disable a DelimitedListTraceListener through the application configuration file and then use the configured DelimitedListTraceListener in your application. Alternately, you can create a DelimitedListTraceListener in your code.
Note
The DelimitedListTraceListener delimits only text that is emitted by using the methods that have names starting with the word Trace, such as DelimitedListTraceListener.TraceEvent or Trace.TraceWarning. Trace data that is emitted by using the Debug.Write and TextWriterTraceListener.WriteLine methods is not delimited.
To configure a DelimitedListTraceListener, edit the configuration file that corresponds to the name of your application. In this file, you can add a listener, set the properties for a listener, or remove a listener. The configuration file should be formatted as shown in the following example:
<configuration>
<system.diagnostics>
<trace autoflush="false" indentsize="4">
<listeners>
<add name="delimitedListener"
type="System.Diagnostics.DelimitedListTraceListener"
delimiter=","
initializeData="delimitedOutput.csv"
traceOutputOptions="ProcessId, DateTime" />
</listeners>
</trace>
</system.diagnostics>
</configuration>
Note
If you try to write to a file that is in use or unavailable, the file name is automatically prefixed by a GUID.
Note
Listeners are intended to be used by methods of the Debug, Trace, and TraceSource classes to write trace information. Listener methods, except for constructors, should not be called directly from application code.
Constructors
| DelimitedListTraceListener(Stream) |
Initializes a new instance of the DelimitedListTraceListener class that writes to the specified output stream. |
| DelimitedListTraceListener(TextWriter) |
Initializes a new instance of the DelimitedListTraceListener class that writes to the specified text writer. |
| DelimitedListTraceListener(String) |
Initializes a new instance of the DelimitedListTraceListener class that writes to the specified file. |
| DelimitedListTraceListener(Stream, String) |
Initializes a new instance of the DelimitedListTraceListener class that writes to the specified output stream and has the specified name. |
| DelimitedListTraceListener(TextWriter, String) |
Initializes a new instance of the DelimitedListTraceListener class that writes to the specified text writer and has the specified name. |
| DelimitedListTraceListener(String, String) |
Initializes a new instance of the DelimitedListTraceListener class that writes to the specified file and has the specified name. |
Properties
| Delimiter |
Gets or sets the delimiter for the delimited list. |
Methods
| GetSupportedAttributes() |
Returns the custom configuration file attribute supported by the delimited trace listener. |
| TraceData(TraceEventCache, String, TraceEventType, Int32, Object) |
Writes trace information, a data object, and event information to the output file or stream. |
| TraceData(TraceEventCache, String, TraceEventType, Int32, Object[]) |
Writes trace information, an array of data objects, and event information to the output file or stream. |
| TraceEvent(TraceEventCache, String, TraceEventType, Int32, String) |
Writes trace information, a message, and event information to the output file or stream. |
| TraceEvent(TraceEventCache, String, TraceEventType, Int32, String, Object[]) |
Writes trace information, a formatted array of objects, and event information to the output file or stream. |