diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c9f7c76..93e2fe17 100644 --- a/CHANGELOG.md +++ b/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 API endpoint to empty trash (POST to `/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 - Fix error message about synchronizing Plex collections from a Plex server that has zero collections diff --git a/ErsatzTV/Startup.cs b/ErsatzTV/Startup.cs index c9060eda..872a7d72 100644 --- a/ErsatzTV/Startup.cs +++ b/ErsatzTV/Startup.cs @@ -506,6 +506,14 @@ public class Startup 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(