diff options
| author | Vasily <just.one.man@yandex.ru> | 2020-04-06 14:42:41 +0300 |
|---|---|---|
| committer | Vasily <just.one.man@yandex.ru> | 2020-04-06 14:42:41 +0300 |
| commit | 71d8e66d9fbca1d448d8d4ec7c1fe9be55134076 (patch) | |
| tree | ca8fc07675253cb9a6b250357dd1087f5d48ee17 | |
| parent | 0cd7cd611e6118b8dac31cf3c6861509f2b33c56 (diff) | |
Add logging of URL being processed when logging an error
This might help diagnosing stuff like "Operation was cancelled"
| -rw-r--r-- | Emby.Server.Implementations/HttpServer/HttpListenerHost.cs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index 72667a314..c12862145 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.IO; using System.Linq; using System.Net.Sockets; @@ -239,19 +240,22 @@ namespace Emby.Server.Implementations.HttpServer } } - private async Task ErrorHandler(Exception ex, IRequest httpReq, bool logExceptionStackTrace) + private async Task ErrorHandler(Exception ex, IRequest httpReq, bool logExceptionStackTrace, string urlToLog) { + string urlSuffix = string.IsNullOrWhiteSpace(urlToLog) + ? string.Format(CultureInfo.InvariantCulture, "; URL being processed: {0}", urlToLog) + : ""; try { ex = GetActualException(ex); if (logExceptionStackTrace) { - _logger.LogError(ex, "Error processing request"); + _logger.LogError(ex, "Error processing request{Suffix}", urlSuffix); } else { - _logger.LogError("Error processing request: {Message}", ex.Message); + _logger.LogError("Error processing request: {Message}{Suffix}", ex.Message, urlSuffix); } var httpRes = httpReq.Response; @@ -271,7 +275,7 @@ namespace Emby.Server.Implementations.HttpServer } catch (Exception errorEx) { - _logger.LogError(errorEx, "Error this.ProcessRequest(context)(Exception while writing error to the response)"); + _logger.LogError(errorEx, "Error this.ProcessRequest(context)(Exception while writing error to the response){Suffix}", urlSuffix); } } @@ -553,7 +557,7 @@ namespace Emby.Server.Implementations.HttpServer || ex is OperationCanceledException || ex is SecurityException || ex is FileNotFoundException; - await ErrorHandler(ex, httpReq, ignoreStackTrace).ConfigureAwait(false); + await ErrorHandler(ex, httpReq, ignoreStackTrace, urlToLog).ConfigureAwait(false); } finally { |
