I am adding a trace function to the ASP.NET website, so I decided to investigate TraceSource by creating a couple of prototypes; web application design and website design.
I use a similar Web.config for each project to register traces in the Windows event log:
<configuration>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0"/>
</system.web>
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="HelloWorld">
<listeners>
<add name="eventlogListener" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="eventlogListener" type="System.Diagnostics.EventLogTraceListener" initializeData="My Source" />
</sharedListeners>
</system.diagnostics>
</configuration>
I just start with the following basic trace:
private static TraceSource _ts = new TraceSource("HelloWorld", SourceLevels.All);
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
_ts.TraceEvent(TraceEventType.Information, 10, "Greetings from OnLoad.");
}
In the Web Application project, I see the trace created in the event log. However, with a website project I cannot.
Are there additional steps (for example: web.config settings, permissions, etc.) needed to use website projects to use TraceSource?
source
share