Skip to content

Commit

Permalink
Version 5.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
snakefoot committed Aug 17, 2022
1 parent 223946f commit 396dae5
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 67 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ See also [releases](https://github.com/NLog/NLog.Web/releases) and [milestones](

Date format: (year/month/day)

### Version 5.1.1 (2022/08/17)

- **NLog.Web.AspNetCore**
- [#836](https://github.com/NLog/NLog.Web/pull/836) Fixed offset by one in AspNetRequestDurationLayoutRenderer (#836) (@snakefoot)
- [#840](https://github.com/NLog/NLog.Web/pull/840) Added option LowercaseKeys for ${aspnet-request-querystring} (#840) (@czd890)
- [#845](https://github.com/NLog/NLog.Web/pull/845) Added ${aspnet-request-has-posted-body} Layout Renderer (#845) (@bakgerman)
- [#845](https://github.com/NLog/NLog.Web/pull/845) Added ${aspnet-request-stream-id} Layout Renderer (#845) (@bakgerman)
- [#850](https://github.com/NLog/NLog.Web/pull/850) + [#853](https://github.com/NLog/NLog.Web/pull/853) Improved re-Entrancy scope lock for Session Value Layout Render (#850) (@bakgerman)
- [#854](https://github.com/NLog/NLog.Web/pull/854) Updated dependency NLog.Extensions.Logging v5.0.2 (#854) (@snakefoot)
- [#856](https://github.com/NLog/NLog.Web/pull/856) Added option Properties for ${aspnet-request-url} instead of booleans (#856) (@bakgerman)

- **NLog.Web**
- [#836](https://github.com/NLog/NLog.Web/pull/836) Fixed offset by one in AspNetRequestDurationLayoutRenderer (#836) (@snakefoot)
- [#840](https://github.com/NLog/NLog.Web/pull/840) Added option LowercaseKeys for ${aspnet-request-querystring} (#840) (@czd890)
- [#854](https://github.com/NLog/NLog.Web/pull/854) Updated dependency NLog v5.0.2 (#854) (@snakefoot)
- [#856](https://github.com/NLog/NLog.Web/pull/856) Added option Properties for ${aspnet-request-url} instead of booleans (#856) (@bakgerman)

### Version 5.1.0 (2022/07/18)

- **NLog.Web.AspNetCore**
Expand Down
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# creates NuGet package at \artifacts
dotnet --version

$versionPrefix = "5.1" # Also update version for minor versions in appveyor.yml
$versionPrefix = "5.1.1" # Also update version for minor versions in appveyor.yml
$versionSuffix = ""
$versionFile = $versionPrefix + "." + ${env:APPVEYOR_BUILD_NUMBER}
if ($env:APPVEYOR_PULL_REQUEST_NUMBER) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ namespace NLog.Web.LayoutRenderers
/// <remarks>
/// <code>${aspnet-request-has-body}</code>
/// </remarks>
[LayoutRenderer("aspnet-request-has-body")]
public class AspNetRequestHasBodyLayoutRenderer : AspNetLayoutRendererBase
/// <seealso href="https://github.com/NLog/NLog/wiki/AspNet-Request-Has-Posted-Body-Layout-Renderer">Documentation on NLog Wiki</seealso>
[LayoutRenderer("aspnet-request-has-posted-body")]
public class AspNetRequestHasPostedBodyLayoutRenderer : AspNetLayoutRendererBase
{
/// <inheritdoc/>
protected override void DoAppend(StringBuilder builder, LogEventInfo logEvent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ namespace NLog.Web.LayoutRenderers
/// <remarks>
/// <code>${aspnet-request-stream-id}</code>
/// </remarks>
/// <seealso href="https://github.com/NLog/NLog/wiki/AspNet-Request-StreamId-Layout-Renderer">Documentation on NLog Wiki</seealso>
[LayoutRenderer("aspnet-request-stream-id")]
public class AspNetRequestStreamIdLayoutRenderer : AspNetLayoutRendererBase
{
/// <inheritdoc/>
protected override void DoAppend(StringBuilder builder, LogEventInfo logEvent)
{
var features = HttpContextAccessor.HttpContext.TryGetFeatureCollection();
var streamIdFeature = features?.Get<IStreamIdFeature>();
builder.Append(streamIdFeature?.StreamId);
var streamId = features?.Get<IStreamIdFeature>()?.StreamId ?? 0L;
if (streamId != 0L)
{
builder.Append(streamId);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,9 @@ public class AspNetResponseHttpsCompressionLayoutRenderer : AspNetLayoutRenderer
/// <inheritdoc/>
protected override void DoAppend(StringBuilder builder, LogEventInfo logEvent)
{

var mode = HttpsCompressionMode.Default;
var features = HttpContextAccessor.HttpContext.TryGetFeatureCollection();
var compression = features?.Get<IHttpsCompressionFeature>();
if (compression != null)
{
mode = compression.Mode;
}
builder.Append(mode);

var compressionMode = features?.Get<IHttpsCompressionFeature>()?.Mode ?? HttpsCompressionMode.Default;
builder.Append(compressionMode);
}
}
}
Expand Down
36 changes: 9 additions & 27 deletions src/NLog.Web.AspNetCore/NLog.Web.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,20 @@ Supported platforms:
<PackageId>NLog.Web.AspNetCore</PackageId>
<PackageTags>logging;log;NLog;web;aspnet;aspnetcore;MVC;Microsoft.Extensions.Logging;httpcontext</PackageTags>
<PackageReleaseNotes>
Thank you Burak Akgerman (@bakgerman) for making this huge contribution and restoring ${aspnet-request-posted-body}

## Improvements
- [#836] Fixed offset by one in AspNetRequestDurationLayoutRenderer (@snakefoot)
- [#840] Added option LowercaseKeys for ${aspnet-request-querystring} (@czd890)
- [#845] Added ${aspnet-request-has-posted-body} Layout Renderer (@bakgerman)
- [#845] Added ${aspnet-request-stream-id} Layout Renderer (@bakgerman)
- [#850] + [#853] Improved re-Entrancy scope lock for Session Value Layout Render (@bakgerman)
- [#854] Updated dependency NLog.Extensions.Logging v5.0.2 (@snakefoot)
- [#856] Added option Properties for ${aspnet-request-url} instead of booleans (@bakgerman)

- [#828] Reverted default value for ShutdownOnDispose to false (#828) (@snakefoot)
- [#815] Added ${aspnet-request-trailers} Layout Renderer (#815) (@bakgerman)
- [#815] Added ${aspnet-response-trailers} Layout Renderer (#815) (@bakgerman)
- [#815] Added ${aspnet-response-https-compression} Layout Renderer (#815) (@bakgerman)
- [#815] Added ${aspnet-request-tracking-consent} Layout Renderer (#815) (@bakgerman)
- [#815] Added ${aspnet-request-tls-token-binding} Layout Renderer (#815) (@bakgerman)
- [#815] Added ${aspnet-request-inherent-keep-alive} Layout Renderer (#815) (@bakgerman)
- [#815] Added ${aspnet-request-http-transport-type} Layout Renderer (#815) (@bakgerman)
- [#815] Added ${aspnet-request-bidirectional-stream} Layout Renderer (#815) (@bakgerman)
- [#811] Added ${aspnet-request-servervariable} Layout Renderer (#811) (@bakgerman)
- [#802] Added ${aspnet-request-tls-handshake} Layout Renderer (#802) (@bakgerman)
- [#796] Added ${aspnet-request-connection-id} Layout Renderer (#796) (@bakgerman)
- [#796] Added ${aspnet-response-has-started} Layout Renderer (#796) (@bakgerman)
- [#789] Added ${aspnet-response-cookie} Layout Renderer (#789) (@bakgerman)
- [#785] Added ${aspnet-request-client-certificate} Layout Renderer (#785) (@bakgerman)
- [#785] Added ${aspnet-request-is-web-socket} Layout Renderer (#785) (@bakgerman)
- [#785] Added ${aspnet-request-local-ip} Layout Renderer (#785) (@bakgerman)
- [#785] Added ${aspnet-request-local-port} Layout Renderer (#785) (@bakgerman)
- [#785] Added ${aspnet-request-remote-port} Layout Renderer (#785) (@bakgerman)
- [#785] Added ${aspnet-request-web-socket-requested-protocols} Layout Renderer (#785) (@bakgerman)
- [#785] Added ${aspnet-response-contenttype} Layout Renderer (#785) (@bakgerman)
- [#785] Added ${aspnet-response-headers} Layout Renderer (#785) (@bakgerman)
- [#781] NLogRequestPostedBodyMiddleware - Restore support for ${aspnet-request-posted-body} (#781) (@bakgerman)
- [#783] NLogRequestLoggingMiddleware - Added support for custom ShouldLogRequest-delegate (#783) (@snakefoot)
List of major changes in NLog 5.0: https://nlog-project.org/2022/05/16/nlog-5-0-finally-ready.html

Full changelog: https://github.com/NLog/NLog.Web/releases

NLog 5 release post: https://nlog-project.org/2021/08/25/nlog-5-0-preview1-ready.html
List of available Layout Renderers: https://nlog-project.org/config/?tab=layout-renderers&amp;search=package:nlog.web.aspnetcore
</PackageReleaseNotes>
<PackageIcon>N.png</PackageIcon>
<PackageProjectUrl>https://github.com/NLog/NLog.Web</PackageProjectUrl>
Expand Down
4 changes: 3 additions & 1 deletion src/NLog.Web/NLog.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ Remember to register NLog.Web in NLog.config
&lt;add assembly="NLog.Web" /&gt;
&lt;/extensions&gt;

See https://github.com/NLog/NLog.Web/releases
Full changelog: https://github.com/NLog/NLog.Web/releases

List of available Layout Renderers: https://nlog-project.org/config/?tab=layout-renderers&amp;search=package:nlog.web
</PackageReleaseNotes>
<PackageIcon>N.png</PackageIcon>
<PackageProjectUrl>https://github.com/NLog/NLog.Web</PackageProjectUrl>
Expand Down
10 changes: 5 additions & 5 deletions src/Shared/LayoutRenderers/AspNetRequestUrlRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class AspNetRequestUrlRenderer : AspNetLayoutRendererBase
/// <summary>
/// To specify whether to include / exclude the Query string. Default is false.
/// </summary>
[Obsolete("Please use the Properties flags enumeration instead")]
[Obsolete("Please use the Properties flags enumeration instead. Marked obsolete on NLog.Web 5.1")]
public bool IncludeQueryString
{
get => HasPropertiesFlag(AspNetRequestUrlProperty.Query);
Expand All @@ -49,7 +49,7 @@ public bool IncludeQueryString
/// <summary>
/// To specify whether to include / exclude the Port. Default is false.
/// </summary>
[Obsolete("Please use the Properties flags enumeration instead")]
[Obsolete("Please use the Properties flags enumeration instead. Marked obsolete on NLog.Web 5.1")]
public bool IncludePort
{
get => HasPropertiesFlag(AspNetRequestUrlProperty.Port);
Expand All @@ -59,7 +59,7 @@ public bool IncludePort
/// <summary>
/// To specify whether to exclude / include the host. Default is true.
/// </summary>
[Obsolete("Please use the Properties flags enumeration instead")]
[Obsolete("Please use the Properties flags enumeration instead. Marked obsolete on NLog.Web 5.1")]
public bool IncludeHost
{
get => HasPropertiesFlag(AspNetRequestUrlProperty.Host);
Expand All @@ -69,7 +69,7 @@ public bool IncludeHost
/// <summary>
/// To specify whether to exclude / include the scheme. Ex. 'http' or 'https'. Default is true.
/// </summary>
[Obsolete("Please use the Properties flags enumeration instead")]
[Obsolete("Please use the Properties flags enumeration instead. Marked obsolete on NLog.Web 5.1")]
public bool IncludeScheme
{
get => HasPropertiesFlag(AspNetRequestUrlProperty.Scheme);
Expand All @@ -79,7 +79,7 @@ public bool IncludeScheme
/// <summary>
/// To specify whether to exclude / include the url-path. Default is true.
/// </summary>
[Obsolete("Please use the Properties flags enumeration instead")]
[Obsolete("Please use the Properties flags enumeration instead. Marked obsolete on NLog.Web 5.1")]
public bool IncludePath
{
get => HasPropertiesFlag(AspNetRequestUrlProperty.Path);
Expand Down
7 changes: 1 addition & 6 deletions src/Shared/LayoutRenderers/AspNetSessionIdLayoutRenderer.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
using System.Text;
using NLog.Common;
using NLog.Config;
using NLog.LayoutRenderers;
using NLog.Web.Internal;

#if !ASP_NET_CORE
using System.Web;
#endif

namespace NLog.Web.LayoutRenderers
{
/// <summary>
Expand All @@ -31,7 +26,7 @@ protected override void DoAppend(StringBuilder builder, LogEventInfo logEvent)
{
if (!reEntryScopeLock.IsLockAcquired)
{
InternalLogger.Debug("aspnet-session-item - Lookup skipped because reentrant-scope-lock already taken");
InternalLogger.Debug("aspnet-session-id - Lookup skipped because reentrant-scope-lock already taken");
return;
}
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace NLog.Web.Tests.LayoutRenderers
{
public class AspNetRequestHasBodyLayoutRendererTests : LayoutRenderersTestBase<AspNetRequestHasBodyLayoutRenderer>
public class AspNetRequestHasPostedBodyLayoutRendererTests : LayoutRenderersTestBase<AspNetRequestHasPostedBodyLayoutRenderer>
{
[Fact]
public void TrueTest()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,6 @@ public void NullTest()
// Assert
Assert.Equal(string.Empty, result);
}

protected override void NullRendersEmptyString()
{
// Arrange
var (renderer, _) = CreateWithHttpContext();

// Act
string result = renderer.Render(LogEventInfo.CreateNullEvent());

// Assert
Assert.Equal("0", result);
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net461;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<AssemblyName>NLog.Web.AspNetCore.Tests</AssemblyName>
<AssemblyVersion>1.2.3.0</AssemblyVersion>
<FileVersion>1.2.3.1</FileVersion>
Expand Down
11 changes: 11 additions & 0 deletions tests/Shared/LayoutRenderers/AspNetRequestUrlRendererTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using NLog.Web.LayoutRenderers;
using NSubstitute;
using Xunit;
using System;

#if ASP_NET_CORE
using System.IO;
Expand All @@ -26,6 +27,7 @@ public void UrlPresentRenderNonEmpty_Default()
}

[Fact]
[Obsolete("Please use the Properties flags enumeration instead. Marked obsolete on NLog.Web 5.1")]
public void UrlPresentRenderNonEmpty_IncludeQueryString()
{
var renderer = CreateRenderer("www.google.com:80", "?t=1", "http");
Expand All @@ -38,6 +40,7 @@ public void UrlPresentRenderNonEmpty_IncludeQueryString()
}

[Fact]
[Obsolete("Please use the Properties flags enumeration instead. Marked obsolete on NLog.Web 5.1")]
public void UrlPresentRenderNonEmpty_IncludeQueryString_IncludePort()
{
var renderer = CreateRenderer("www.google.com:80", "?t=1", "http", "/Test.asp");
Expand All @@ -50,6 +53,7 @@ public void UrlPresentRenderNonEmpty_IncludeQueryString_IncludePort()
}

[Fact]
[Obsolete("Please use the Properties flags enumeration instead. Marked obsolete on NLog.Web 5.1")]
public void UrlPresentRenderNonEmpty_IncludeQueryString_ExcludePort()
{
var renderer = CreateRenderer("www.google.com:80", "?t=1", "http", "/Test.asp");
Expand All @@ -73,6 +77,7 @@ public void UrlPresentRenderNonEmpty_ExcludeQueryString_ExcludePort()
}

[Fact]
[Obsolete("Please use the Properties flags enumeration instead. Marked obsolete on NLog.Web 5.1")]
public void UrlPresentRenderNonEmpty_ExcludeScheme()
{
var renderer = CreateRenderer("www.google.com:80", "?t=1", "http", "/Test.asp");
Expand All @@ -84,6 +89,7 @@ public void UrlPresentRenderNonEmpty_ExcludeScheme()
}

[Fact]
[Obsolete("Please use the Properties flags enumeration instead. Marked obsolete on NLog.Web 5.1")]
public void UrlPresentRenderNonEmpty_ExcludeScheme_IncludePort_IncludeQueryString()
{
var renderer = CreateRenderer("www.google.com:80", "?t=1", "http", "/Test.asp");
Expand All @@ -97,6 +103,7 @@ public void UrlPresentRenderNonEmpty_ExcludeScheme_IncludePort_IncludeQueryStrin
}

[Fact]
[Obsolete("Please use the Properties flags enumeration instead. Marked obsolete on NLog.Web 5.1")]
public void UrlPresentRenderNonEmpty_ExcludeScheme_IncludePort()
{
var renderer = CreateRenderer("www.google.com:80", "?t=1", "http", "/Test.asp");
Expand All @@ -109,6 +116,7 @@ public void UrlPresentRenderNonEmpty_ExcludeScheme_IncludePort()
}

[Fact]
[Obsolete("Please use the Properties flags enumeration instead. Marked obsolete on NLog.Web 5.1")]
public void UrlPresentRenderNonEmpty_ExcludeScheme_ExcludeHost()
{
var renderer = CreateRenderer("www.google.com:80", "?t=1", "http", "/Test.asp");
Expand All @@ -121,6 +129,7 @@ public void UrlPresentRenderNonEmpty_ExcludeScheme_ExcludeHost()
}

[Fact]
[Obsolete("Please use the Properties flags enumeration instead. Marked obsolete on NLog.Web 5.1")]
public void UrlPresentRenderNonEmpty_ExcludeHost()
{
var renderer = CreateRenderer("www.google.com:80", "?t=1", "http", "/Test.asp");
Expand All @@ -132,6 +141,7 @@ public void UrlPresentRenderNonEmpty_ExcludeHost()
}

[Fact]
[Obsolete("Please use the Properties flags enumeration instead. Marked obsolete on NLog.Web 5.1")]
public void UrlPresentRenderNonEmpty_ExcludeHost_IncludeQueryString()
{
var renderer = CreateRenderer("www.google.com:80", "?t=1", "http", "/Test.asp");
Expand All @@ -155,6 +165,7 @@ public void UrlPresentRenderNonEmpty_UseRawTarget()
}

[Fact]
[Obsolete("Please use the Properties flags enumeration instead. Marked obsolete on NLog.Web 5.1")]
public void UrlPresentRenderNonEmpty_UseRawTarget_IncludeQueryString()
{
var renderer = CreateRenderer("www.google.com:80", "?t=1", "http", "/Test.asp", rawTarget: "/rawTarget");
Expand Down

0 comments on commit 396dae5

Please sign in to comment.