1

I'm hosting a Web API in IIS (7.5) as an Application under "Default Web Site", and am using several of the Enrichers from Serilog.Extras.Web (I'll be upgrading soon to the SerilogWeb.Classic package). I noticed in my logs that ApplicationLifecycleModule.LogRequest() was being called twice for each request, and I'm trying to understand why.

What I noticed is that ApplicationLifecycleModule.Init() is being called twice, thus registering two event handlers.

The first callstack:

Serilog.Extras.Web.dll!Serilog.Extras.Web.ApplicationLifecycleModule.Init(System.Web.HttpApplication context)
System.Web.dll!System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(System.IntPtr appContext, System.Web.HttpContext context, System.Reflection.MethodInfo[] handlers)
System.Web.dll!System.Web.HttpApplication.InitSpecial(System.Web.HttpApplicationState state, System.Reflection.MethodInfo[] handlers, System.IntPtr appContext, System.Web.HttpContext context)
System.Web.dll!System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(System.IntPtr appContext, System.Web.HttpContext context)
System.Web.dll!System.Web.Hosting.PipelineRuntime.InitializeApplication(System.IntPtr appContext)
[AppDomain Transition]

And the second:

Serilog.Extras.Web.dll!Serilog.Extras.Web.ApplicationLifecycleModule.Init(System.Web.HttpApplication context)
System.Web.dll!System.Web.HttpApplication.InitModulesCommon()
System.Web.dll!System.Web.HttpApplication.InitInternal(System.Web.HttpContext context, System.Web.HttpApplicationState state, System.Reflection.MethodInfo[] handlers)
System.Web.dll!System.Web.HttpApplicationFactory.GetNormalApplicationInstance(System.Web.HttpContext context)
System.Web.dll!System.Web.HttpApplicationFactory.GetApplicationInstance(System.Web.HttpContext context)
System.Web.dll!System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest wr, System.Web.HttpContext context)
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags)
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags)

Am I doing something wrong? Or is this a bug in the ApplicationLifecycleModule?

David Rubin
  • 1,610
  • 1
  • 17
  • 28
  • I haven't seen this previously - may be a bug, or a quirk in `PreApplicationStartMethod` handling; raising a ticket on the "classic" GitHub tracker might bring some ideas/input. Cheers! – Nicholas Blumhardt Apr 10 '15 at 20:58
  • @David Google brought me here I've got exactly same issue. Did you get any further on the cause? – Jafin Jul 03 '15 at 04:23
  • In my case I had the same issue, turns out I had both Serilog.Extras.Web and SerilogWeb.Classic in my bin folder both autoregistering. But this doesn't seem to match your stacktrace namespaces, so probably separate issue. – Jafin Jul 03 '15 at 04:45

0 Answers0