Skip to content

Default to not including the query string in logged RequestPath #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,6 @@ __pycache__/
*.btm.cs
*.odx.cs
*.xsd.cs

samples/Sample/logs/

56 changes: 0 additions & 56 deletions samples/Sample/logs/log-20210214.txt

This file was deleted.

4 changes: 2 additions & 2 deletions src/Serilog.AspNetCore/AspNetCore/RequestLoggingOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ static LogEventLevel DefaultGetLevel(HttpContext ctx, double _, Exception ex) =>

/// <summary>
/// Include the full URL query string in the <c>RequestPath</c> property
/// that is attached to request log events. The default is <c>true</c>.
/// that is attached to request log events. The default is <c>false</c>.
/// </summary>
public bool IncludeQueryInRequestPath { get; set; } = true;
public bool IncludeQueryInRequestPath { get; set; }

/// <summary>
/// Constructor
Expand Down
12 changes: 8 additions & 4 deletions src/Serilog.AspNetCore/Serilog.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>Serilog support for ASP.NET Core logging</Description>
<VersionPrefix>4.1.1</VersionPrefix>
<VersionPrefix>5.0.0</VersionPrefix>
<Authors>Microsoft;Serilog Contributors</Authors>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand All @@ -24,11 +24,15 @@
<None Include="..\..\assets\icon.png" Pack="true" Visible="false" PackagePath="" />
</ItemGroup>

<PropertyGroup Condition="'$(TargetFramework)' != 'netstandard2.0' and '$(TargetFramework)' != 'netstandard2.1'">
<DefineConstants>$(DefineConstants);HOSTBUILDER</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="4.1.2" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="4.2.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
<PackageReference Include="Serilog.Formatting.Compact" Version="1.1.0" />
Expand Down
6 changes: 6 additions & 0 deletions src/Serilog.AspNetCore/SerilogWebHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public static class SerilogWebHostBuilderExtensions
/// <c>WriteTo.Providers()</c> configuration method, enabling other <see cref="ILoggerProvider"/>s to receive events. By
/// default, only Serilog sinks will receive events.</param>
/// <returns>The web host builder.</returns>
#if HOSTBUILDER
[Obsolete("Prefer UseSerilog() on IHostBuilder")]
#endif
public static IWebHostBuilder UseSerilog(
this IWebHostBuilder builder,
ILogger logger = null,
Expand Down Expand Up @@ -83,6 +86,9 @@ public static IWebHostBuilder UseSerilog(
/// the Microsoft.Extensions.Logging API. Normally, equivalent Serilog sinks are used in place of providers. Specify
/// <c>true</c> to write events to all providers.</param>
/// <returns>The web host builder.</returns>
#if HOSTBUILDER
[Obsolete("Prefer UseSerilog() on IHostBuilder")]
#endif
public static IWebHostBuilder UseSerilog(
this IWebHostBuilder builder,
Action<WebHostBuilderContext, LoggerConfiguration> configureLogger,
Expand Down
4 changes: 2 additions & 2 deletions test/Serilog.AspNetCore.Tests/Serilog.AspNetCore.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" PrivateAssets="All" />
<PackageReference Include="xunit" Version="2.4.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
using Serilog.Filters;
using Serilog.AspNetCore.Tests.Support;

// Newer frameworks provide IHostBuilder
#pragma warning disable CS0618

namespace Serilog.AspNetCore.Tests
{
public class SerilogWebHostBuilderExtensionsTests : IClassFixture<SerilogWebApplicationFactory>
Expand Down