Tracelistener

Simple listener

<configuration>
 
<connectionStrings>
    <add name="DBConnection" connectionString="Data Source=localhost;Initial Catalog=MyDatabase;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>
</connectionStrings>
    <system.diagnostics>
        <trace autoflush="true" indentsize="4">
            <listeners>
                <remove name="Default"/>
                    <add name="traceListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\Inetpub\wwwroot\MyServer\trace.log"/>
            </listeners>
        </trace>
    </system.diagnostics>
</configuration>

Writing to Event Log

<system.diagnostics>
        <trace autoflush="true" indentsize="4">
            <listeners>
                <add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="c:\MediaRippingService.log" />
                <remove name="Default" />
            </listeners>
        </trace>
    </system.diagnostics>

Set default notification level

<system.diagnostics >
        <trace autoflush="true" indentsize="2">
            <listeners>
                <remove name="Default"/>
                <add name="EventLogListener" type="System.Diagnostics.EventLogTraceListener,System" initializeData="Lex.Service"/>
            </listeners>
        </trace>
        <switches>
            <!-- Options; "1" Errors, "2" As 1 plus warnings, "3" As 2 plus informational, "4" As 3 plus Verbose -->
            <add name="TraceLevelSwitch" value="2" />
        </switches>
    </system.diagnostics>
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License