System.Diagnostics.Trace.AutoFlush Property

Gets or sets whether Trace.Flush should be called on the Trace.Listeners after every write.


public static bool AutoFlush { get; set; }


Whether or not the System.Diagnostics.TraceListener objects should be TraceListener.Flushed after each write.


The default is false.

Flushing the stream will not flush its underlying encoder unless you explicitly call Trace.Flush or Trace.Close. Setting Trace.AutoFlush to true means that data will be flushed from the buffer to the stream, but the encoder state will not be flushed. This allows the encoder to keep its state (partial characters) so that it can encode the next block of characters correctly. This scenario affects UTF8 and UTF7 where certain characters can only be encoded after the encoder receives the adjacent character or characters.

To set the Trace.AutoFlush and Trace.IndentSize for System.Diagnostics.Trace, you can also edit the configuration file that corresponds to the name of your application. The configuration file should be formatted like the following example:


    <trace autoflush="false" indentsize="3" />


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