Skip to content

Commit 1aa0a4b

Browse files
authored
Merge pull request #352 from serilog/dev
8.0.0 Release
2 parents 086bb07 + e8212c8 commit 1aa0a4b

File tree

11 files changed

+74
-280
lines changed

11 files changed

+74
-280
lines changed

Build.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ foreach ($src in ls src/*) {
2525
} else {
2626
& dotnet pack -c Release --include-source -o ..\..\artifacts
2727
}
28-
29-
if($LASTEXITCODE -ne 0) { exit 1 }
28+
29+
if($LASTEXITCODE -ne 0) { exit 1 }
3030

3131
Pop-Location
3232
}

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"sdk": {
33
"allowPrerelease": false,
4-
"version": "7.0.100",
4+
"version": "8.0.100",
55
"rollForward": "latestFeature"
66
}
77
}

samples/Sample/Program.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Serilog;
2+
using Serilog.Templates;
23

34
namespace Sample;
45

@@ -24,7 +25,7 @@ public static int Main(string[] args)
2425
}
2526
catch (Exception ex)
2627
{
27-
Log.Fatal(ex, "An unhandled exception occured during bootstrapping");
28+
Log.Fatal(ex, "An unhandled exception occurred during bootstrapping");
2829
return 1;
2930
}
3031
finally
@@ -39,6 +40,8 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
3940
.ReadFrom.Configuration(context.Configuration)
4041
.ReadFrom.Services(services)
4142
.Enrich.FromLogContext()
42-
.WriteTo.Console())
43-
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
44-
}
43+
.WriteTo.Console(new ExpressionTemplate(
44+
// Include trace and span ids when present.
45+
"[{@t:HH:mm:ss} {@l:u3}{#if @tr is not null} ({substring(@tr,0,4)}:{substring(@sp,0,4)}){#end}] {@m}\n{@x}")))
46+
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>());
47+
}

samples/Sample/Sample.csproj

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

3-
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
5-
</PropertyGroup>
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
</PropertyGroup>
66

7-
<ItemGroup>
8-
<ProjectReference Include="..\..\src\Serilog.AspNetCore\Serilog.AspNetCore.csproj" />
9-
</ItemGroup>
7+
<ItemGroup>
8+
<ProjectReference Include="..\..\src\Serilog.AspNetCore\Serilog.AspNetCore.csproj" />
9+
</ItemGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Serilog.Expressions" Version="4.0.0" />
13+
</ItemGroup>
1014

1115
</Project>

src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class RequestLoggingMiddleware
3232
readonly Func<HttpContext, string, double, int, IEnumerable<LogEventProperty>> _getMessageTemplateProperties;
3333
readonly ILogger? _logger;
3434
readonly bool _includeQueryInRequestPath;
35-
static readonly LogEventProperty[] NoProperties = new LogEventProperty[0];
35+
static readonly LogEventProperty[] NoProperties = Array.Empty<LogEventProperty>();
3636

3737
public RequestLoggingMiddleware(RequestDelegate next, DiagnosticContext diagnosticContext, RequestLoggingOptions options)
3838
{
@@ -82,7 +82,6 @@ bool LogCompletion(HttpContext httpContext, DiagnosticContextCollector collector
8282

8383
if (!logger.IsEnabled(level)) return false;
8484

85-
// Enrich diagnostic context
8685
_enrichDiagnosticContext?.Invoke(_diagnosticContext, httpContext);
8786

8887
if (!collector.TryComplete(out var collectedProperties, out var collectedException))
@@ -91,7 +90,19 @@ bool LogCompletion(HttpContext httpContext, DiagnosticContextCollector collector
9190
// Last-in (correctly) wins...
9291
var properties = collectedProperties.Concat(_getMessageTemplateProperties(httpContext, GetPath(httpContext, _includeQueryInRequestPath), elapsedMs, statusCode));
9392

94-
var evt = new LogEvent(DateTimeOffset.Now, level, ex ?? collectedException, _messageTemplate, properties);
93+
var (traceId, spanId) = Activity.Current is { } activity ?
94+
(activity.TraceId, activity.SpanId) :
95+
(default(ActivityTraceId), default(ActivitySpanId));
96+
97+
var evt = new LogEvent(
98+
DateTimeOffset.Now,
99+
level,
100+
ex ?? collectedException,
101+
_messageTemplate,
102+
properties,
103+
traceId,
104+
spanId);
105+
95106
logger.Write(evt);
96107

97108
return false;

src/Serilog.AspNetCore/AspNetCore/SerilogLoggerFactory.cs

Lines changed: 0 additions & 71 deletions
This file was deleted.

src/Serilog.AspNetCore/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<Description>Serilog support for ASP.NET Core logging</Description>
55
<!-- This must match the major and minor components of the referenced *.Extensions.* packages (and highest supported .NET TFM). -->
6-
<VersionPrefix>7.0.0</VersionPrefix>
6+
<VersionPrefix>8.0.0</VersionPrefix>
77
<Authors>Microsoft;Serilog Contributors</Authors>
8-
<TargetFrameworks>net462;netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
8+
<TargetFrameworks>net462;netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
99
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1010
<PackageTags>serilog;aspnet;aspnetcore</PackageTags>
1111
<PackageIcon>icon.png</PackageIcon>
@@ -15,36 +15,41 @@
1515
<RepositoryType>git</RepositoryType>
1616
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
1717
<RootNamespace>Serilog</RootNamespace>
18+
<PackageReadmeFile>README.md</PackageReadmeFile>
1819
</PropertyGroup>
1920

2021
<ItemGroup>
2122
<None Include="..\..\assets\icon.png" Pack="true" Visible="false" PackagePath="" />
23+
<None Include="..\..\README.md" Pack="true" Visible="false" PackagePath="/" />
24+
<InternalsVisibleTo Include="Serilog.AspNetCore.Tests" Key="0024000004800000940000000602000000240000525341310004000001000100fb8d13fd344a1c6fe0fe83ef33c1080bf30690765bc6eb0df26ebfdf8f21670c64265b30db09f73a0dea5b3db4c9d18dbf6d5a25af5ce9016f281014d79dc3b4201ac646c451830fc7e61a2dfd633d34c39f87b81894191652df5ac63cc40c77f3542f702bda692e6e8a9158353df189007a49da0f3cfd55eb250066b19485ec" />
2225
</ItemGroup>
23-
26+
2427
<ItemGroup>
25-
<PackageReference Include="Serilog" Version="2.12.0" />
26-
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
28+
<PackageReference Include="Serilog" Version="3.1.1" />
29+
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.0" />
2730
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
2831
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" />
29-
<PackageReference Include="Serilog.Formatting.Compact" Version="1.1.0" />
32+
<PackageReference Include="Serilog.Formatting.Compact" Version="2.0.0" />
3033
</ItemGroup>
31-
34+
3235
<ItemGroup>
3336
<!-- The versions of all references in this group must match the major and minor components of the package version prefix. -->
34-
<PackageReference Include="Serilog.Extensions.Hosting" Version="7.0.0" />
35-
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
36-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
37-
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
37+
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
38+
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
39+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
40+
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
41+
<!-- Temporary addition to pull in trace/span support -->
42+
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
3843
</ItemGroup>
3944

40-
<ItemGroup Condition=" '$(TargetFramework)' != 'net462' and '$(TargetFramework)' != 'netstandard2.0' and '$(TargetFramework)' != 'netstandard2.1' ">
45+
<ItemGroup Condition=" '$(TargetFramework)' != 'net462' and '$(TargetFramework)' != 'netstandard2.0' ">
4146
<!-- I.e. all modern/supported non-Framework .NET SKUs -->
4247
<FrameworkReference Include="Microsoft.AspNetCore.App" />
4348
</ItemGroup>
44-
45-
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netstandard2.1' ">
49+
50+
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'netstandard2.0' ">
4651
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
4752
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
4853
</ItemGroup>
49-
54+
5055
</Project>

0 commit comments

Comments
 (0)