我将跟踪功能添加到ASP.NET网站,因此我决定通过创建几个原型来调查TraceSource;一个Web应用程序项目和一个网站项目。TraceSource和ASP.NET:适用于Web应用程序,而不适用于WebSites
我使用类似的Web.config每个项目登录痕迹,Windows事件日志:
<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>
我只是以下基本跟踪开始:
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.");
}
随着在Web应用程序项目中,我可以看到在事件日志中创建的跟踪。但是,通过网站项目,我不能。
是否需要网站项目使用TraceSource的附加步骤(例如:web.config设置,权限等)?
额外的步骤是停止使用网站。 – 2011-03-17 18:23:55
目前没有选项。 – Bullines 2011-03-17 18:24:52