From 288a66b961c6b549336dc5c20c1751bc7137ad73 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 5 Sep 2017 12:23:31 +1000 Subject: [PATCH 1/9] Remove deployment step to fix build status --- appveyor.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index c13bd52..14c15dd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,17 +13,3 @@ build_script: test: off artifacts: - path: artifacts/Serilog.*.nupkg -deploy: -- provider: NuGet - api_key: - secure: nvZ/z+pMS91b3kG4DgfES5AcmwwGoBYQxr9kp4XiJHj25SAlgdIxFx++1N0lFH2x - skip_symbols: true - on: - branch: /^(master|dev)$/ -- provider: GitHub - auth_token: - secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX - artifact: /Serilog.*\.nupkg/ - tag: v$(appveyor_build_version) - on: - branch: master From e374103b1c6a837fbda683f83f53283d53158948 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 5 Sep 2017 12:23:55 +1000 Subject: [PATCH 2/9] Re-enable deployment [Skip CI] --- appveyor.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 14c15dd..c13bd52 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,3 +13,17 @@ build_script: test: off artifacts: - path: artifacts/Serilog.*.nupkg +deploy: +- provider: NuGet + api_key: + secure: nvZ/z+pMS91b3kG4DgfES5AcmwwGoBYQxr9kp4XiJHj25SAlgdIxFx++1N0lFH2x + skip_symbols: true + on: + branch: /^(master|dev)$/ +- provider: GitHub + auth_token: + secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX + artifact: /Serilog.*\.nupkg/ + tag: v$(appveyor_build_version) + on: + branch: master From 4920e8fe02481ca4452d6d95f3fb53aa945cd34e Mon Sep 17 00:00:00 2001 From: "Jie-Ren (Jarron) Shih" <1546735+jarronshih@users.noreply.github.com> Date: Thu, 23 Sep 2021 09:54:33 -0700 Subject: [PATCH 3/9] Update RequestLoggingMiddleware.cs --- src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs index dee6a5d..5ac6579 100644 --- a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs +++ b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs @@ -111,10 +111,10 @@ static string GetPath(HttpContext httpContext) { /* In some cases, like when running integration tests with WebApplicationFactory - the RawTarget returns an empty string instead of null, in that case we can't use + the Path returns an empty string instead of null, in that case we can't use ?? as fallback. */ - var requestPath = httpContext.Features.Get()?.RawTarget; + var requestPath = httpContext.Features.Get()?.Path; if (string.IsNullOrEmpty(requestPath)) { requestPath = httpContext.Request.Path.ToString(); From 27f597a5f6c7ea4cfa69acf71773c8919f4510a6 Mon Sep 17 00:00:00 2001 From: Jie-Ren Shih Date: Mon, 27 Sep 2021 14:19:41 -0700 Subject: [PATCH 4/9] add option --- .../AspNetCore/RequestLoggingMiddleware.cs | 10 +++++++--- .../AspNetCore/RequestLoggingOptions.cs | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs index 5ac6579..56bb862 100644 --- a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs +++ b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs @@ -33,6 +33,7 @@ class RequestLoggingMiddleware readonly Action _enrichDiagnosticContext; readonly Func _getLevel; readonly ILogger _logger; + readonly bool _includeRawTargetPath; static readonly LogEventProperty[] NoProperties = new LogEventProperty[0]; public RequestLoggingMiddleware(RequestDelegate next, DiagnosticContext diagnosticContext, RequestLoggingOptions options) @@ -45,6 +46,7 @@ public RequestLoggingMiddleware(RequestDelegate next, DiagnosticContext diagnost _enrichDiagnosticContext = options.EnrichDiagnosticContext; _messageTemplate = new MessageTemplateParser().Parse(options.MessageTemplate); _logger = options.Logger?.ForContext(); + _includeRawTargetPath = options.IncludeRawTargetPath; } // ReSharper disable once UnusedMember.Global @@ -91,7 +93,7 @@ bool LogCompletion(HttpContext httpContext, DiagnosticContextCollector collector var properties = collectedProperties.Concat(new[] { new LogEventProperty("RequestMethod", new ScalarValue(httpContext.Request.Method)), - new LogEventProperty("RequestPath", new ScalarValue(GetPath(httpContext))), + new LogEventProperty("RequestPath", new ScalarValue(GetPath(httpContext, _includeRawTargetPath))), new LogEventProperty("StatusCode", new ScalarValue(statusCode)), new LogEventProperty("Elapsed", new ScalarValue(elapsedMs)) }); @@ -107,14 +109,16 @@ static double GetElapsedMilliseconds(long start, long stop) return (stop - start) * 1000 / (double)Stopwatch.Frequency; } - static string GetPath(HttpContext httpContext) + static string GetPath(HttpContext httpContext, bool includeRawTargetPath) { /* In some cases, like when running integration tests with WebApplicationFactory the Path returns an empty string instead of null, in that case we can't use ?? as fallback. */ - var requestPath = httpContext.Features.Get()?.Path; + var requestPath = includeRawTargetPath + ? httpContext.Features.Get()?.RawTarget + : httpContext.Features.Get()?.Path; if (string.IsNullOrEmpty(requestPath)) { requestPath = httpContext.Request.Path.ToString(); diff --git a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs index 8d86582..d3cf234 100644 --- a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs +++ b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs @@ -68,6 +68,11 @@ static LogEventLevel DefaultGetLevel(HttpContext ctx, double _, Exception ex) => /// public ILogger Logger { get; set; } + /// + /// + /// + public bool IncludeRawTargetPath { get; set; } = true; + /// /// Constructor /// From a965f351e5476fe75763d7c8b355cc7d392a96e4 Mon Sep 17 00:00:00 2001 From: Jie-Ren Shih Date: Sun, 10 Oct 2021 11:58:48 -0700 Subject: [PATCH 5/9] Add summary doc --- src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs index d3cf234..04bc27c 100644 --- a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs +++ b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs @@ -69,7 +69,9 @@ static LogEventLevel DefaultGetLevel(HttpContext ctx, double _, Exception ex) => public ILogger Logger { get; set; } /// - /// + /// Include raw request path in "RequestPath" or not. The default is + /// true for backward compatibility. Raw request path contains url query + /// patameters and values. /// public bool IncludeRawTargetPath { get; set; } = true; From aba4698e013dde26d2d4e51dcf92d0ebff693cd2 Mon Sep 17 00:00:00 2001 From: "Jie-Ren (Jarron) Shih" <1546735+jarronshih@users.noreply.github.com> Date: Sun, 10 Oct 2021 12:35:42 -0700 Subject: [PATCH 6/9] Update src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs Co-authored-by: Ivan Maximov --- src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs index 04bc27c..6af1701 100644 --- a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs +++ b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs @@ -71,7 +71,7 @@ static LogEventLevel DefaultGetLevel(HttpContext ctx, double _, Exception ex) => /// /// Include raw request path in "RequestPath" or not. The default is /// true for backward compatibility. Raw request path contains url query - /// patameters and values. + /// parameters and values. /// public bool IncludeRawTargetPath { get; set; } = true; From a06c6b71d448d71059c90d301c4232fa85e593e1 Mon Sep 17 00:00:00 2001 From: Jie-Ren Shih Date: Mon, 8 Nov 2021 16:51:05 -0800 Subject: [PATCH 7/9] rename to IncludeQueryInPath --- .../AspNetCore/RequestLoggingMiddleware.cs | 10 +++++----- .../AspNetCore/RequestLoggingOptions.cs | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs index 56bb862..15c7a26 100644 --- a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs +++ b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs @@ -33,7 +33,7 @@ class RequestLoggingMiddleware readonly Action _enrichDiagnosticContext; readonly Func _getLevel; readonly ILogger _logger; - readonly bool _includeRawTargetPath; + readonly bool _includeQueryInPath; static readonly LogEventProperty[] NoProperties = new LogEventProperty[0]; public RequestLoggingMiddleware(RequestDelegate next, DiagnosticContext diagnosticContext, RequestLoggingOptions options) @@ -46,7 +46,7 @@ public RequestLoggingMiddleware(RequestDelegate next, DiagnosticContext diagnost _enrichDiagnosticContext = options.EnrichDiagnosticContext; _messageTemplate = new MessageTemplateParser().Parse(options.MessageTemplate); _logger = options.Logger?.ForContext(); - _includeRawTargetPath = options.IncludeRawTargetPath; + _includeQueryInPath = options.IncludeQueryInPath; } // ReSharper disable once UnusedMember.Global @@ -93,7 +93,7 @@ bool LogCompletion(HttpContext httpContext, DiagnosticContextCollector collector var properties = collectedProperties.Concat(new[] { new LogEventProperty("RequestMethod", new ScalarValue(httpContext.Request.Method)), - new LogEventProperty("RequestPath", new ScalarValue(GetPath(httpContext, _includeRawTargetPath))), + new LogEventProperty("RequestPath", new ScalarValue(GetPath(httpContext, _includeQueryInPath))), new LogEventProperty("StatusCode", new ScalarValue(statusCode)), new LogEventProperty("Elapsed", new ScalarValue(elapsedMs)) }); @@ -109,14 +109,14 @@ static double GetElapsedMilliseconds(long start, long stop) return (stop - start) * 1000 / (double)Stopwatch.Frequency; } - static string GetPath(HttpContext httpContext, bool includeRawTargetPath) + static string GetPath(HttpContext httpContext, bool includeQueryInPath) { /* In some cases, like when running integration tests with WebApplicationFactory the Path returns an empty string instead of null, in that case we can't use ?? as fallback. */ - var requestPath = includeRawTargetPath + var requestPath = includeQueryInPath ? httpContext.Features.Get()?.RawTarget : httpContext.Features.Get()?.Path; if (string.IsNullOrEmpty(requestPath)) diff --git a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs index 6af1701..35f09c4 100644 --- a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs +++ b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs @@ -69,11 +69,11 @@ static LogEventLevel DefaultGetLevel(HttpContext ctx, double _, Exception ex) => public ILogger Logger { get; set; } /// - /// Include raw request path in "RequestPath" or not. The default is - /// true for backward compatibility. Raw request path contains url query + /// Include query in "RequestPath" or not. The default is + /// true for backward compatibility. This includes both query /// parameters and values. /// - public bool IncludeRawTargetPath { get; set; } = true; + public bool IncludeQueryInPath { get; set; } = true; /// /// Constructor From e100d8b60159104f59efbd8aed5d685449faf20a Mon Sep 17 00:00:00 2001 From: Jie-Ren Shih Date: Wed, 10 Nov 2021 18:38:50 -0800 Subject: [PATCH 8/9] change naming --- .../AspNetCore/RequestLoggingMiddleware.cs | 10 +++++----- .../AspNetCore/RequestLoggingOptions.cs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs index 15c7a26..cc2d84b 100644 --- a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs +++ b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs @@ -33,7 +33,7 @@ class RequestLoggingMiddleware readonly Action _enrichDiagnosticContext; readonly Func _getLevel; readonly ILogger _logger; - readonly bool _includeQueryInPath; + readonly bool _includeQueryInRequestPath; static readonly LogEventProperty[] NoProperties = new LogEventProperty[0]; public RequestLoggingMiddleware(RequestDelegate next, DiagnosticContext diagnosticContext, RequestLoggingOptions options) @@ -46,7 +46,7 @@ public RequestLoggingMiddleware(RequestDelegate next, DiagnosticContext diagnost _enrichDiagnosticContext = options.EnrichDiagnosticContext; _messageTemplate = new MessageTemplateParser().Parse(options.MessageTemplate); _logger = options.Logger?.ForContext(); - _includeQueryInPath = options.IncludeQueryInPath; + _includeQueryInRequestPath = options.IncludeQueryInRequestPath; } // ReSharper disable once UnusedMember.Global @@ -93,7 +93,7 @@ bool LogCompletion(HttpContext httpContext, DiagnosticContextCollector collector var properties = collectedProperties.Concat(new[] { new LogEventProperty("RequestMethod", new ScalarValue(httpContext.Request.Method)), - new LogEventProperty("RequestPath", new ScalarValue(GetPath(httpContext, _includeQueryInPath))), + new LogEventProperty("RequestPath", new ScalarValue(GetPath(httpContext, _includeQueryInRequestPath))), new LogEventProperty("StatusCode", new ScalarValue(statusCode)), new LogEventProperty("Elapsed", new ScalarValue(elapsedMs)) }); @@ -109,14 +109,14 @@ static double GetElapsedMilliseconds(long start, long stop) return (stop - start) * 1000 / (double)Stopwatch.Frequency; } - static string GetPath(HttpContext httpContext, bool includeQueryInPath) + static string GetPath(HttpContext httpContext, bool includeQueryInRequestPath) { /* In some cases, like when running integration tests with WebApplicationFactory the Path returns an empty string instead of null, in that case we can't use ?? as fallback. */ - var requestPath = includeQueryInPath + var requestPath = includeQueryInRequestPath ? httpContext.Features.Get()?.RawTarget : httpContext.Features.Get()?.Path; if (string.IsNullOrEmpty(requestPath)) diff --git a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs index 35f09c4..dd1928f 100644 --- a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs +++ b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs @@ -73,7 +73,7 @@ static LogEventLevel DefaultGetLevel(HttpContext ctx, double _, Exception ex) => /// true for backward compatibility. This includes both query /// parameters and values. /// - public bool IncludeQueryInPath { get; set; } = true; + public bool IncludeQueryInRequestPath { get; set; } = true; /// /// Constructor From 9e2ce19b31f790c5f903563cdb6a1286de32f32b Mon Sep 17 00:00:00 2001 From: Jie-Ren Shih Date: Wed, 10 Nov 2021 18:40:44 -0800 Subject: [PATCH 9/9] improve doc --- src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs index dd1928f..1c7b434 100644 --- a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs +++ b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs @@ -69,9 +69,8 @@ static LogEventLevel DefaultGetLevel(HttpContext ctx, double _, Exception ex) => public ILogger Logger { get; set; } /// - /// Include query in "RequestPath" or not. The default is - /// true for backward compatibility. This includes both query - /// parameters and values. + /// Include the full URL query string in the RequestPath property + /// that is attached to request log events. The default is true. /// public bool IncludeQueryInRequestPath { get; set; } = true;