TraceListener Třída
Definice
Poskytuje abstract
základní třídu pro naslouchací procesy, které monitorují výstup trasování a ladění.Provides the abstract
base class for the listeners who monitor trace and debug output.
public ref class TraceListener abstract : MarshalByRefObject, IDisposable
public ref class TraceListener abstract : IDisposable
public abstract class TraceListener : MarshalByRefObject, IDisposable
public abstract class TraceListener : IDisposable
type TraceListener = class
inherit MarshalByRefObject
interface IDisposable
type TraceListener = class
interface IDisposable
Public MustInherit Class TraceListener
Inherits MarshalByRefObject
Implements IDisposable
Public MustInherit Class TraceListener
Implements IDisposable
- Dědičnost
- Dědičnost
-
TraceListener
- Odvozené
- Implementuje
Poznámky
Příklady, jak implementovat TraceListener , naleznete v tématu DefaultTraceListener TextWriterTraceListener a EventLogTraceListener třídy.For examples of how to implement a TraceListener, see the DefaultTraceListener, TextWriterTraceListener and the EventLogTraceListener classes.
Chcete-li použít naslouchací proces trasování, je nutné povolit trasování nebo ladění.You must enable tracing or debugging to use a trace listener. Následující syntaxe je specifická pro kompilátor.The following syntax is compiler specific. Pokud používáte jiné kompilátory než C# nebo Visual Basic, přečtěte si dokumentaci k vašemu kompilátoru.If you use compilers other than C# or Visual Basic, refer to the documentation for your compiler.
Chcete-li povolit ladění v jazyce C#, přidejte
/d:DEBUG
příznak do příkazového řádku kompilátoru při kompilování kódu nebo můžete přidat#define DEBUG
do horní části souboru.To enable debugging in C#, add the/d:DEBUG
flag to the compiler command line when you compile your code, or you can add#define DEBUG
to the top of your file. V Visual Basic přidejte/d:DEBUG=True
příznak do příkazového řádku kompilátoru.In Visual Basic, add the/d:DEBUG=True
flag to the compiler command line.Chcete-li povolit trasování v jazyce C#, přidejte
/d:TRACE
příznak do příkazového řádku kompilátoru při kompilování kódu nebo přidejte#define TRACE
do horní části souboru.To enable tracing in C#, add the/d:TRACE
flag to the compiler command line when you compile your code, or add#define TRACE
to the top of your file. V Visual Basic přidejte/d:TRACE=True
příznak do příkazového řádku kompilátoru.In Visual Basic, add the/d:TRACE=True
flag to the compiler command line.
Chcete-li přidat naslouchací proces trasování, upravte konfigurační soubor, který odpovídá názvu vaší aplikace.To add a trace listener, edit the configuration file that corresponds to the name of your application. V tomto souboru můžete přidat naslouchací proces, nastavit jeho typ a nastavit jeho parametr, odebrat naslouchací proces, nebo zrušit všechny naslouchací procesy, které dříve nastavila aplikace.Within this file, you can add a listener, set its type and set its parameter, remove a listener, or clear all the listeners previously set by the application. Konfigurační soubor by měl být formátován podobně jako v následujícím příkladu.The configuration file should be formatted similar to the following example.
<configuration>
<system.diagnostics>
<trace autoflush="false" indentsize="4">
<listeners>
<add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="TextWriterOutput.log" />
<remove name="Default" />
</listeners>
</trace>
</system.diagnostics>
</configuration>
Další informace o použití konfiguračních souborů pro trasování naleznete v tématu < System. Diagnostics > .For more information on using configuration files for tracing, see <system.diagnostics>.
Poznámky pro implementátory
Dědí z této třídy pro implementaci vlastního naslouchacího procesu pro Debug třídy a Trace .Inherit from this class to implement a custom listener for the Debug and Trace classes. Přinejmenším je nutné implementovat Write(String) WriteLine(String) metody a.At a minimum, you must implement the Write(String) and WriteLine(String) methods. Kromě toho můžete implementovat Fail(String) Close() Flush() metody a.Additionally, you can implement the Fail(String), Close() and Flush() methods.
Konstruktory
TraceListener() |
Inicializuje novou instanci TraceListener třídy.Initializes a new instance of the TraceListener class. |
TraceListener(String) |
Inicializuje novou instanci TraceListener třídy pomocí zadaného názvu jako naslouchací proces.Initializes a new instance of the TraceListener class using the specified name as the listener. |
Vlastnosti
Attributes |
Získá vlastní atributy naslouchacího procesu trasování definované v konfiguračním souboru aplikace.Gets the custom trace listener attributes defined in the application configuration file. |
Filter |
Získá nebo nastaví filtr trasování pro naslouchací proces trasování.Gets or sets the trace filter for the trace listener. |
IndentLevel |
Získá nebo nastaví úroveň odsazení.Gets or sets the indent level. |
IndentSize |
Získá nebo nastaví počet mezer v odsazení.Gets or sets the number of spaces in an indent. |
IsThreadSafe |
Načte hodnotu, která označuje, zda je naslouchací proces trasování bezpečný pro přístup z více vláken.Gets a value indicating whether the trace listener is thread safe. |
Name |
Získá nebo nastaví název pro tuto hodnotu TraceListener .Gets or sets a name for this TraceListener. |
NeedIndent |
Získá nebo nastaví hodnotu označující, zda má být výstup odsazen.Gets or sets a value indicating whether to indent the output. |
TraceOutputOptions |
Získá nebo nastaví možnosti výstupu trasování.Gets or sets the trace output options. |
Metody
Close() |
Při přepsání v odvozené třídě zavře výstupní datový proud, takže již nepřijímá trasování nebo ladění výstupu.When overridden in a derived class, closes the output stream so it no longer receives tracing or debugging output. |
CreateObjRef(Type) |
Vytvoří objekt, který obsahuje všechny relevantní informace požadované pro vygenerování proxy serveru, který se používá ke komunikaci se vzdáleným objektem.Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Zděděno od MarshalByRefObject) |
Dispose() |
Uvolní všechny prostředky, které používá TraceListener .Releases all resources used by the TraceListener. |
Dispose(Boolean) |
Uvolní nespravované prostředky používané TraceListener a volitelně uvolňuje spravované prostředky.Releases the unmanaged resources used by the TraceListener and optionally releases the managed resources. |
Equals(Object) |
Určí, zda se zadaný objekt rovná aktuálnímu objektu.Determines whether the specified object is equal to the current object. (Zděděno od Object) |
Fail(String) |
Vygeneruje chybovou zprávu pro naslouchací proces, který vytvoříte při implementaci TraceListener třídy.Emits an error message to the listener you create when you implement the TraceListener class. |
Fail(String, String) |
Vygeneruje chybovou zprávu a podrobnou chybovou zprávu pro naslouchací proces, který vytvoříte při implementaci TraceListener třídy.Emits an error message and a detailed error message to the listener you create when you implement the TraceListener class. |
Flush() |
Při přepsání v odvozené třídě vyprázdní výstupní vyrovnávací paměť.When overridden in a derived class, flushes the output buffer. |
GetHashCode() |
Slouží jako výchozí funkce hash.Serves as the default hash function. (Zděděno od Object) |
GetLifetimeService() |
Zastaralé.
Načte aktuální objekt služby životnosti, který řídí zásady životního cyklu pro tuto instanci.Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Zděděno od MarshalByRefObject) |
GetSupportedAttributes() |
Získá vlastní atributy, které podporuje naslouchací proces trasování.Gets the custom attributes supported by the trace listener. |
GetType() |
Získá Type aktuální instanci.Gets the Type of the current instance. (Zděděno od Object) |
InitializeLifetimeService() |
Zastaralé.
Získá objekt služby životnosti, který řídí zásady životního cyklu pro tuto instanci.Obtains a lifetime service object to control the lifetime policy for this instance. (Zděděno od MarshalByRefObject) |
MemberwiseClone() |
Vytvoří kopii aktuálního seznamu Object .Creates a shallow copy of the current Object. (Zděděno od Object) |
MemberwiseClone(Boolean) |
Vytvoří kopii aktuálního objektu bez podstruktury MarshalByRefObject .Creates a shallow copy of the current MarshalByRefObject object. (Zděděno od MarshalByRefObject) |
ToString() |
Vrátí řetězec, který představuje aktuální objekt.Returns a string that represents the current object. (Zděděno od Object) |
TraceData(TraceEventCache, String, TraceEventType, Int32, Object) |
Zapisuje trasovací informace, datový objekt a informace o události do výstupu specifického pro naslouchací proces.Writes trace information, a data object and event information to the listener specific output. |
TraceData(TraceEventCache, String, TraceEventType, Int32, Object[]) |
Zapisuje trasovací informace, pole datových objektů a informací o událostech do výstupu specifického pro naslouchací proces.Writes trace information, an array of data objects and event information to the listener specific output. |
TraceEvent(TraceEventCache, String, TraceEventType, Int32) |
Zapisuje informace o trasování a události do výstupu specifického pro naslouchací proces.Writes trace and event information to the listener specific output. |
TraceEvent(TraceEventCache, String, TraceEventType, Int32, String) |
Zapisuje informace o trasování, zprávu a událost do výstupu specifického pro naslouchací proces.Writes trace information, a message, and event information to the listener specific output. |
TraceEvent(TraceEventCache, String, TraceEventType, Int32, String, Object[]) |
Zapisuje informace o trasování, formátované pole objektů a informací o událostech na výstup konkrétního naslouchacího procesu.Writes trace information, a formatted array of objects and event information to the listener specific output. |
TraceTransfer(TraceEventCache, String, Int32, String, Guid) |
Zapisuje informace o trasování, zprávu, informace o identitě a události související aktivity do výstupního konkrétního naslouchacího procesu.Writes trace information, a message, a related activity identity and event information to the listener specific output. |
Write(Object) |
Zapíše hodnotu ToString() metody objektu pro naslouchací proces, který vytvoříte při implementaci TraceListener třídy.Writes the value of the object's ToString() method to the listener you create when you implement the TraceListener class. |
Write(Object, String) |
Zapíše název kategorie a hodnotu ToString() metody objektu pro naslouchací proces, který vytvoříte při implementaci TraceListener třídy.Writes a category name and the value of the object's ToString() method to the listener you create when you implement the TraceListener class. |
Write(String) |
Při přepsání v odvozené třídě zapíše určenou zprávu na naslouchací proces, který vytvoříte v odvozené třídě.When overridden in a derived class, writes the specified message to the listener you create in the derived class. |
Write(String, String) |
Zapíše název kategorie a zprávu do naslouchacího procesu, který vytvoříte při implementaci TraceListener třídy.Writes a category name and a message to the listener you create when you implement the TraceListener class. |
WriteIndent() |
Zapíše odsazení do naslouchacího procesu, který vytvoříte při implementaci této třídy, a obnoví NeedIndent vlastnost na |
WriteLine(Object) |
Zapíše hodnotu ToString() metody objektu pro naslouchací proces, který vytvoříte při implementaci TraceListener třídy následovaný ukončovacím znakem řádku.Writes the value of the object's ToString() method to the listener you create when you implement the TraceListener class, followed by a line terminator. |
WriteLine(Object, String) |
Zapíše název kategorie a hodnotu ToString() metody objektu pro naslouchací proces, který vytvoříte při implementaci TraceListener třídy následovaný ukončovacím znakem řádku.Writes a category name and the value of the object's ToString() method to the listener you create when you implement the TraceListener class, followed by a line terminator. |
WriteLine(String) |
Při přepsání v odvozené třídě zapíše zprávu do naslouchacího procesu, který vytvoříte v odvozené třídě následovanou zakončením řádku.When overridden in a derived class, writes a message to the listener you create in the derived class, followed by a line terminator. |
WriteLine(String, String) |
Zapíše název kategorie a zprávu do naslouchacího procesu, který vytvoříte při implementaci TraceListener třídy následovaný ukončovacím znakem řádku.Writes a category name and a message to the listener you create when you implement the TraceListener class, followed by a line terminator. |
Platí pro
Bezpečný přístup z více vláken
Tento typ je bezpečný pro přístup z více vláken.This type is thread safe.