<listeners > elemento per <Trace ><listeners> Element for <trace>
Specifica un listener che raccoglie, archivia e instrada i messaggi.Specifies a listener that collects, stores, and routes messages. I listener indirizzano l'output di traccia a una destinazione appropriata.Listeners direct the tracing output to an appropriate target.
<configuration> <configuration>
Nelle sezioni seguenti vengono descritti gli attributi, gli elementi figlio e gli elementi padre.The following sections describe attributes, child elements, and parent elements. Nessuna.None. Le classi Debug e Trace condividono la stessa raccolta Listeners .The Debug and Trace classes share the same Listeners collection. Se si aggiunge un oggetto listener alla raccolta in una di queste classi, l'altra classe utilizzerà lo stesso listener.If you add a listener object to the collection in one of these classes, the other class uses the same listener. Le classi del listener fornite con la .NET Framework derivano dalla classe TraceListener.The listener classes shipped with the .NET Framework derive from the TraceListener class. Questo elemento può essere utilizzato nel file di configurazione del computer (Machine. config) e nel file di configurazione dell'applicazione.This element can be used in the machine configuration file (Machine.config) and the application configuration file. Nell'esempio seguente viene illustrato come utilizzare l'elemento > listener< per aggiungere i listener
<System. diagnostics > <system.diagnostics>
<Trace > <trace></span>
listener< <listeners>SintassiSyntax
<listeners>
<add>...</add>
<clear/>
<remove ... />
</listeners>
Attributi ed elementiAttributes and Elements
AttributiAttributes
Elementi figlioChild Elements
ElementoElement
DescrizioneDescription
<add><add>
Aggiunge un listener alla raccolta
Listeners
.Adds a listener to the Listeners
collection.
<clear><clear>
Cancella la raccolta
Listeners
per una traccia.Clears the Listeners
collection for trace.
<remove><remove>
Rimuove un listener dalla raccolta di
Listeners
.Removes a listener from the Listeners
collection.Elementi padreParent Elements
ElementoElement
DescrizioneDescription
configuration
Elemento radice in ciascun file di configurazione usato in Common Language Runtime e nelle applicazioni .NET Framework.The root element in every configuration file used by the common language runtime and .NET Framework applications.
system.diagnostics
Consente di specificare l'elemento radice per la sezione di configurazione ASP.NET.Specifies the root element for the ASP.NET configuration section.
trace
Contiene i listener che raccolgono, archiviano e indirizzano i messaggi di traccia.Contains listeners that collect, store, and route tracing messages.
NoteRemarks
File di configurazioneConfiguration File
EsempioExample
MyListener
e MyEventListener
alla raccolta Listeners .The following example shows how to use the <listeners> element to add the listeners MyListener
and MyEventListener
to the Listeners collection. MyListener
crea un file denominato MyListener.log
e scrive l'output nel file.MyListener
creates a file called MyListener.log
and writes the output to the file. MyEventListener
crea una voce nel registro eventi.MyEventListener
creates an entry in the event log.<configuration>
<system.diagnostics>
<trace autoflush="true" indentsize="0">
<listeners>
<add name="myListener"
type="System.Diagnostics.TextWriterTraceListener,
system, version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
initializeData="c:\myListener.log" />
<add name="MyEventListener"
type="System.Diagnostics.EventLogTraceListener,
system, version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
initializeData="MyConfigEventLog"/>
</listeners>
</trace>
</system.diagnostics>
</configuration>
Vedere ancheSee also
Commenti
Caricamento dei commenti...