add remote ip and user agent to http request logging (#1990)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user