Edit

Share via


XmlWriterTraceListener Constructors

Definition

Initializes a new instance of the XmlWriterTraceListener class.

Overloads

XmlWriterTraceListener(Stream)

Initializes a new instance of the XmlWriterTraceListener class, using the specified stream as the recipient of the debugging and tracing output.

XmlWriterTraceListener(TextWriter)

Initializes a new instance of the XmlWriterTraceListener class using the specified writer as the recipient of the debugging and tracing output.

XmlWriterTraceListener(String)

Initializes a new instance of the XmlWriterTraceListener class, using the specified file as the recipient of the debugging and tracing output.

XmlWriterTraceListener(Stream, String)

Initializes a new instance of the XmlWriterTraceListener class with the specified name, using the specified stream as the recipient of the debugging and tracing output.

XmlWriterTraceListener(TextWriter, String)

Initializes a new instance of the XmlWriterTraceListener class with the specified name, using the specified writer as the recipient of the debugging and tracing output.

XmlWriterTraceListener(String, String)

Initializes a new instance of the XmlWriterTraceListener class with the specified name, using the specified file as the recipient of the debugging and tracing output.

XmlWriterTraceListener(Stream)

Source:
XmlWriterTraceListener.cs
Source:
XmlWriterTraceListener.cs
Source:
XmlWriterTraceListener.cs

Initializes a new instance of the XmlWriterTraceListener class, using the specified stream as the recipient of the debugging and tracing output.

public:
 XmlWriterTraceListener(System::IO::Stream ^ stream);
public XmlWriterTraceListener (System.IO.Stream stream);
new System.Diagnostics.XmlWriterTraceListener : System.IO.Stream -> System.Diagnostics.XmlWriterTraceListener
Public Sub New (stream As Stream)

Parameters

stream
Stream

A Stream that represents the stream the trace listener writes to.

Exceptions

stream is null.

Remarks

The Name property is initialized to an empty string ("").

Applies to

XmlWriterTraceListener(TextWriter)

Source:
XmlWriterTraceListener.cs
Source:
XmlWriterTraceListener.cs
Source:
XmlWriterTraceListener.cs

Initializes a new instance of the XmlWriterTraceListener class using the specified writer as the recipient of the debugging and tracing output.

public:
 XmlWriterTraceListener(System::IO::TextWriter ^ writer);
public XmlWriterTraceListener (System.IO.TextWriter writer);
new System.Diagnostics.XmlWriterTraceListener : System.IO.TextWriter -> System.Diagnostics.XmlWriterTraceListener
Public Sub New (writer As TextWriter)

Parameters

writer
TextWriter

A TextWriter that receives the output from the trace listener.

Exceptions

writer is null.

Remarks

The Name property is initialized to an empty string ("").

Applies to

XmlWriterTraceListener(String)

Source:
XmlWriterTraceListener.cs
Source:
XmlWriterTraceListener.cs
Source:
XmlWriterTraceListener.cs

Initializes a new instance of the XmlWriterTraceListener class, using the specified file as the recipient of the debugging and tracing output.

public:
 XmlWriterTraceListener(System::String ^ filename);
public XmlWriterTraceListener (string? filename);
public XmlWriterTraceListener (string filename);
new System.Diagnostics.XmlWriterTraceListener : string -> System.Diagnostics.XmlWriterTraceListener
Public Sub New (filename As String)

Parameters

filename
String

The name of the file to write to.

Exceptions

filename is null.

Remarks

This constructor initializes a new instance of the StreamWriter class for the specified file on the specified path, using UTF8 encoding. If the file exists, it is appended to. If the file does not exist, a new file is created.

Note

To reduce the chance of an exception, any character that might invalidate the output is replaced with a "?" character.

The Name property is initialized to an empty string ("").

Applies to

XmlWriterTraceListener(Stream, String)

Source:
XmlWriterTraceListener.cs
Source:
XmlWriterTraceListener.cs
Source:
XmlWriterTraceListener.cs

Initializes a new instance of the XmlWriterTraceListener class with the specified name, using the specified stream as the recipient of the debugging and tracing output.

public:
 XmlWriterTraceListener(System::IO::Stream ^ stream, System::String ^ name);
public XmlWriterTraceListener (System.IO.Stream stream, string? name);
public XmlWriterTraceListener (System.IO.Stream stream, string name);
new System.Diagnostics.XmlWriterTraceListener : System.IO.Stream * string -> System.Diagnostics.XmlWriterTraceListener
Public Sub New (stream As Stream, name As String)

Parameters

stream
Stream

A Stream that represents the stream the trace listener writes to.

name
String

The name of the new instance.

Exceptions

stream is null.

Remarks

This constructor initializes the Name property to the name parameter value or to an empty string ("") if the name parameter is null. The name can be used as an index into the Trace.Listeners collection to programmatically change the properties for the listener. For example, the following code sets the TraceOutputOptions property for an instance of XmlWriterTraceListener whose Name property is "xmlListener".

((XmlWriterTraceListener)Trace.Listeners["xmlListener"]).TraceOutputOptions =   
    TraceOptions.Timestamp  

Applies to

XmlWriterTraceListener(TextWriter, String)

Source:
XmlWriterTraceListener.cs
Source:
XmlWriterTraceListener.cs
Source:
XmlWriterTraceListener.cs

Initializes a new instance of the XmlWriterTraceListener class with the specified name, using the specified writer as the recipient of the debugging and tracing output.

public:
 XmlWriterTraceListener(System::IO::TextWriter ^ writer, System::String ^ name);
public XmlWriterTraceListener (System.IO.TextWriter writer, string? name);
public XmlWriterTraceListener (System.IO.TextWriter writer, string name);
new System.Diagnostics.XmlWriterTraceListener : System.IO.TextWriter * string -> System.Diagnostics.XmlWriterTraceListener
Public Sub New (writer As TextWriter, name As String)

Parameters

writer
TextWriter

A TextWriter that receives the output from the trace listener.

name
String

The name of the new instance.

Exceptions

writer is null.

Remarks

This constructor initializes the Name property to the name parameter value or to an empty string ("") if the name parameter is null. The name can be used as an index into the Trace.Listeners collection to programmatically change the properties for the listener. For example, the following code sets the TraceOutputOptions property for an instance of XmlWriterTraceListener whose Name property is "xmlListener".

((XmlWriterTraceListener)Trace.Listeners["xmlListener"]).TraceOutputOptions =   
    TraceOptions.Timestamp.  

Applies to

XmlWriterTraceListener(String, String)

Source:
XmlWriterTraceListener.cs
Source:
XmlWriterTraceListener.cs
Source:
XmlWriterTraceListener.cs

Initializes a new instance of the XmlWriterTraceListener class with the specified name, using the specified file as the recipient of the debugging and tracing output.

public:
 XmlWriterTraceListener(System::String ^ filename, System::String ^ name);
public XmlWriterTraceListener (string? filename, string? name);
public XmlWriterTraceListener (string filename, string name);
new System.Diagnostics.XmlWriterTraceListener : string * string -> System.Diagnostics.XmlWriterTraceListener
Public Sub New (filename As String, name As String)

Parameters

filename
String

The name of the file to write to.

name
String

The name of the new instance.

Exceptions

stream is null.

Remarks

This constructor initializes a new instance of the StreamWriter class for the specified file on the specified path, using UTF8 encoding. If the file exists, it is appended to. If the file does not exist, a new file is created.

Note

To reduce the chance of an exception, any character that might invalidate the output is replaced with a "?" character.

The Name property is set to the name parameter value or to an empty string ("") if the name parameter is null. The name can be used as an index into the Trace.Listeners collection to programmatically change the properties for the listener. For example, the following code sets the TraceOutputOptions property for an instance of XmlWriterTraceListener whose Name property is "xmlListener".

((XmlWriterTraceListener)Trace.Listeners["xmlListener"]).TraceOutputOptions =  
    TraceOptions.Timestamp.  

Applies to