serilog-web / classic

Serilog web request logging and enrichment for classic ASP.NET applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple log messages for single Request with error 404

klinki opened this issue · comments

Hi,
I'm facing a problem with getting multiple log messages for a single request. One log message with status 404 (correct one) and one with status 200.

More particular, for requests that ends up with error 404 - and even more interestingly, only for request that doesn't end with file extension.

  • /foo/invalid/request.jpg - this works fine, just a single error 404 is logged
  • /foo/invalid/request - this is broken, multiple messages are logged, first one with error 404 and second one with status 200.

Example:

[15:28:12 INF] HTTP GET /file-manager/backend/permissions/a responded 404 in 0ms
Response sent: http://localhost:36700/file-manager/backend/permissions/a with HTTP status 404.0
[15:28:12 INF] HTTP GET /file-manager/backend/permissions/a responded 200 in 22ms

So far I managed to find out ApplicationLifecycleModule.Init is getting called multiple times and also Application.BeginRequest is called multiple times (which results into multiple calls of WebRequestLoggingHandler.OnBeginRequest). Also LogRequest is called multiple times.

I know ASP.NET is bit dated and now world has moved on to ASP.NET Core, but I still have few old projects to support until we can figure out migration to ASP.NET Core :(

Hey @klinki ,

indeed, not much activity in here ... I can't really do anything to investigate (don't even have access to a Windows machine anymore), but if you can figure something out, maybe we can look for a fix through a PR ...

Maybe something like this is happening ?
https://stackoverflow.com/questions/1140915/httpmodule-init-method-is-called-several-times-why