【问题标题】:Why don't trace listeners log custom handler traffic?为什么不跟踪侦听器记录自定义处理程序流量?
【发布时间】:2011-05-23 23:14:54
【问题描述】:

我有一个这样的自定义处理程序,

public class Handler : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        context.Response.Write("Hello World");
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}

为什么这不起作用?

<system.diagnostics>
  <sources>
    <source name="System.Web" switchValue="All" propagateActivity="true">
      <listeners>
        <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\logs\Traces_Documents.svclog" />
      </listeners>
    </source>
  </sources>
</system.diagnostics>

当它在 web.config 中时,当我调用处理程序时它什么也不做。没有日志记录等。

我之前在 System.ServiceModel 命名空间上使用了相同的跟踪侦听器和 WCF 服务,并且有效。

【问题讨论】:

    标签: asp.net c#-4.0


    【解决方案1】:

    您是否启用了跟踪功能?

    <system.web>
        <trace enabled="true" writeToDiagnosticsTrace="true" />
    </system.web>
    

    另外,您使用的是什么版本的框架/IIS?

    请参阅DnrTV episode w/ Steve Smith,其中包含有关 Asp.Net Tracing 的详细信息。

    【讨论】:

      猜你喜欢
      • 2016-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-06
      • 1970-01-01
      • 2016-03-01
      • 1970-01-01
      • 2017-09-24
      相关资源
      最近更新 更多