System.Diagnostics.DelimitedListTraceListener Class

Directs tracing or debugging output to a text writer, such as a stream writer, or to a stream, such as a file stream.

See Also: DelimitedListTraceListener Members

Syntax

public class DelimitedListTraceListener : TextWriterTraceListener

Remarks

The trace output is in a delimited text format that uses the delimiter specified by the DelimitedListTraceListener.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.

You can enable or disable a System.Diagnostics.DelimitedListTraceListener through the application configuration file and then use the configured System.Diagnostics.DelimitedListTraceListener in your application. Alternately, you can create a System.Diagnostics.DelimitedListTraceListener in your code.

Note:

The System.Diagnostics.DelimitedListTraceListener delimits only text that is emitted by using the methods that have names starting with the word Trace, such as erload:System.Diagnostics.DelimitedListTraceListener.TraceEvent or Trace.TraceWarning(string). Trace data that is emitted by using the erload:System.Diagnostics.Debug.Write and erload:System.Diagnostics.TextWriterTraceListener.WriteLine methods is not delimited.

To configure a System.Diagnostics.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:

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 System.Diagnostics.Debug, System.Diagnostics.Trace, and System.Diagnostics.TraceSource classes to write trace information. Listener methods, except for constructors, should not be called directly from application code.

Requirements

Namespace: System.Diagnostics
Assembly: System (in System.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0