Friday, May 21, 2010

Diagnostics and Logging In ASP.NET

I was playing diagnostic options in asp.net so thought of sharing the information with others.
Scenario
* Log all warnings or above to the event log (So the people will notice it)
* Log all information statements and warnings to text files in the application's
directory.(It will help in detail to idenfy the issue)

<system.diagnostics>

<sources>

<source name="DefaultSource" switchName="DefaultSwitch">

<listeners>

<add name="FileLog"/>

<add name="EventLog"/>

</listeners>

</source>

</sources>

<switches>

<add name="DefaultSwitch" value="Information" />

</switches>

<sharedListeners>

<add name="FileLog"

type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"

initializeData="FileLogWriter"/>

<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="Test Application">

<filter type="System.Diagnostics.EventTypeFilter"

initializeData="Warning" />

</add>

</sharedListeners>

</system.diagnostics>