Name
DefaultTraceListener
Synopsis
This class provides the
default
TraceListener
. By default, an instance of this
class is available in the Listeners
collection of
the Debug
and Trace
classes.
The Write( )
and WriteLine( )
methods output to the log and to the active debugger (if any) via the
Win32 API function OutputDebugString
. The log file
is initially unset, so output goes only to the debugger. To specify a
log file, set LogFileName
. You may also set a
logfile in the <assert>
element of the
application configuration file’s
<system.diagnostics>
section, as in
<assert logfilename="logfile.log"/>
.
AssertUiEnabled
determines whether to use the user
interface for failed assertions. If true
, .NET
uses a dialog box with the options Abort, Retry, or Fail. Whether
this property is set to true
or
false
, .NET always writes messages to the
LogFileName
, if one is specified. The
AssertUiEnabled
property can be set using the
<assert>
element, as in <assert assertuienabled="false"/>
(the default is
true
).
public class DefaultTraceListener : TraceListener { // Public Constructors public DefaultTraceListener( ); // Public Instance Properties public bool AssertUiEnabled{set; get; } public string LogFileName{set; get; } // Public Instance Methods public override void Fail(stringmessage
); // overrides TraceListener public override void Fail(stringmessage
, stringdetailMessage
); // overrides TraceListener public override void Write(stringmessage
); // overrides TraceListener public override void ...
Get C# in a Nutshell, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.