<sources> Element
Specifies trace sources that initiate tracing messages.
<configuration>
<system.diagnostics>
<sources>
Syntax
<sources>
<source>...</source>
</sources>
Attributes and Elements
The following sections describe attributes, child elements, and parent elements.
Attributes
None.
Child Elements
Element | Description |
---|---|
<source> | Required element. Specifies a trace source that initiates tracing messages. |
Parent Elements
Element | Description |
---|---|
configuration |
The root element in every configuration file used by the common language runtime and .NET Framework applications. |
system.diagnostics |
Specifies trace listeners that collect, store, and route messages and the level where a trace switch is set. |
Remarks
This element can be used in the machine configuration file (Machine.config) and the application configuration file.
Example
The following example shows how to use the <sources>
element to add the trace source mySource
and to set the level for the source switch named sourceSwitch
. A console trace listener is added that writes trace information to the console.
<configuration>
<system.diagnostics>
<sources>
<source name="mySource" switchName="sourceSwitch"
switchType="System.Diagnostics.SourceSwitch" >
<listeners>
<add name="console"
type="System.Diagnostics.ConsoleTraceListener" >
<filter type="System.Diagnostics.EventTypeFilter"
initializeData="Error" />
</add>
<remove name="Default" />
</listeners>
</source>
</sources>
<switches>
<add name="sourceSwitch" value="Warning" />
</switches>
</system.diagnostics>
</configuration>
See also
Spolupráca s nami v službe GitHub
Zdroj tohto obsahu nájdete v službe GitHub, kde môžete vytvárať a skúmať problémy a žiadosti o prijatie zmien. Ďalšie informácie nájdete v našom sprievodcovi prispievateľom.