简体   繁体   中英

Provider not executing

I want to implement a provider to do error-logging, but my provider is never called when an error is thrown.

My provider class looks like:

   namespace DynF
{
    public class LoggingProvider : System.Web.Management.BufferedWebEventProvider
    {

        public override void ProcessEventFlush(WebEventBufferFlushInfo flushInfo)
        {
            System.Diagnostics.Debug.WriteLine("logging!");
        }
        public override void ProcessEvent(WebBaseEvent eventRaised)
        {
            System.Diagnostics.Debug.WriteLine("logging!");
        }
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            System.Diagnostics.Debug.WriteLine("logging!");
        }
        public override void Shutdown()
        {
            System.Diagnostics.Debug.WriteLine("logging!");
        }
    }
}

in my web.config I have:

<system.web>
  <healthMonitoring enabled="true">
    <eventMappings>
      <clear/>
      <add name="All Errors"
             type="System.Web.Management.WebBaseErrorEvent, System.Web,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a"
             startEventCode="0"
             endEventCode="2147483647"/>
    </eventMappings>
    <providers>
      <clear/>
      <add name="LoggingProvider" type="DynF.LoggingProvider"/>
    </providers>
    <rules>


      <clear/>
      <add name="LogAllErrors"
        eventName="All Errors"
        provider="LoggingProvider"/>
    </rules>
  </healthMonitoring>
</system.web>

When running a testpage that throws a NonImplementedException, the LoggingProvider never outputs "logging!" (and no breakpoints no matter where put in the LoggingProvider class makes the application stop). I read this tutorial and as far as I understand it this should be enough to make it work.

What is it that I'm missing here?

我需要将buffermode添加为false。

<add name="LoggingProvider" type="DynF.LoggingProvider" buffer="false"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM