mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 05:47:14 -04:00
Change log level for slow HTTP responses from WRN TO DBG
The added log level check is there because Request.GetDisplayUrl() is a pretty expensive call, creating a StringBuilder and string which doesn't need to happen on most installs where debug logging is disabled
This commit is contained in:
parent
fea01a1ccb
commit
b2ce70987c
@ -47,9 +47,10 @@ namespace Jellyfin.Server.Middleware
|
|||||||
context.Response.OnStarting(() =>
|
context.Response.OnStarting(() =>
|
||||||
{
|
{
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
if (enableWarning && watch.ElapsedMilliseconds > warningThreshold)
|
var responseTimeForCompleteRequest = watch.ElapsedMilliseconds;
|
||||||
|
if (enableWarning && responseTimeForCompleteRequest > warningThreshold && _logger.IsEnabled(LogLevel.Debug))
|
||||||
{
|
{
|
||||||
_logger.LogWarning(
|
_logger.LogDebug(
|
||||||
"Slow HTTP Response from {Url} to {RemoteIp} in {Elapsed:g} with Status Code {StatusCode}",
|
"Slow HTTP Response from {Url} to {RemoteIp} in {Elapsed:g} with Status Code {StatusCode}",
|
||||||
context.Request.GetDisplayUrl(),
|
context.Request.GetDisplayUrl(),
|
||||||
context.GetNormalizedRemoteIp(),
|
context.GetNormalizedRemoteIp(),
|
||||||
@ -57,7 +58,6 @@ namespace Jellyfin.Server.Middleware
|
|||||||
context.Response.StatusCode);
|
context.Response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
var responseTimeForCompleteRequest = watch.ElapsedMilliseconds;
|
|
||||||
context.Response.Headers[ResponseHeaderResponseTime] = responseTimeForCompleteRequest.ToString(CultureInfo.InvariantCulture);
|
context.Response.Headers[ResponseHeaderResponseTime] = responseTimeForCompleteRequest.ToString(CultureInfo.InvariantCulture);
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user