Browse Source

add remote ip and user agent to http request logging (#1990)

pull/1992/head
Jason Dove 4 months ago committed by GitHub
parent
commit
6fe6382485
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 8
      ErsatzTV/Startup.cs

1
CHANGELOG.md

@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Add `linux-musl-x64` artifact for users running Alpine x64 - Add `linux-musl-x64` artifact for users running Alpine x64
- Add API endpoint to empty trash (POST to `/api/maintenance/empty_trash`) - Add API endpoint to empty trash (POST to `/api/maintenance/empty_trash`)
- e.g. `curl -XPOST -d '' http://localhost:8409/api/maintenance/empty_trash` - e.g. `curl -XPOST -d '' http://localhost:8409/api/maintenance/empty_trash`
- Add remote IP and user agent to HTTP request logging
### Fixed ### Fixed
- Fix error message about synchronizing Plex collections from a Plex server that has zero collections - Fix error message about synchronizing Plex collections from a Plex server that has zero collections

8
ErsatzTV/Startup.cs

@ -506,6 +506,14 @@ public class Startup
return LogEventLevel.Verbose; return LogEventLevel.Verbose;
}; };
options.EnrichDiagnosticContext = (diagnosticContext, httpContext) =>
{
diagnosticContext.Set("RemoteIP", httpContext.Connection.RemoteIpAddress);
diagnosticContext.Set("UserAgent", httpContext.Request.Headers["User-Agent"]);
};
options.MessageTemplate = "HTTP {RequestMethod} {RequestPath} responded {StatusCode} in {Elapsed:0.00} ms from {UserAgent} at {RemoteIP}";
}); });
app.UseRequestLocalization( app.UseRequestLocalization(

Loading…
Cancel
Save