Skip to content

Commit 6fc0681

Browse files
authored
Merge pull request #53 from serilog/dev
3.0.0 Release
2 parents 0ced1ee + 79a74c8 commit 6fc0681

File tree

10 files changed

+92
-49
lines changed

10 files changed

+92
-49
lines changed

Build.ps1

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,37 @@ echo "build: Build started"
33
Push-Location $PSScriptRoot
44

55
if(Test-Path .\artifacts) {
6-
echo "build: Cleaning .\artifacts"
7-
Remove-Item .\artifacts -Force -Recurse
6+
echo "build: Cleaning .\artifacts"
7+
Remove-Item .\artifacts -Force -Recurse
88
}
99

1010
& dotnet restore --no-cache
1111

1212
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
1313
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
14-
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"]
14+
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "main" -and $revision -ne "local"]
1515
$commitHash = $(git rev-parse --short HEAD)
1616
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
1717

1818
echo "build: Package version suffix is $suffix"
19-
echo "build: Build version suffix is $buildSuffix"
19+
echo "build: Build version suffix is $buildSuffix"
2020

2121
foreach ($src in ls src/*) {
2222
Push-Location $src
2323

24-
echo "build: Packaging project in $src"
24+
echo "build: Packaging project in $src"
2525

2626
& dotnet build -c Release --version-suffix=$buildSuffix
2727
& dotnet pack -c Release --include-symbols -o ..\..\artifacts --version-suffix=$suffix --no-build
28-
if($LASTEXITCODE -ne 0) { exit 1 }
28+
if($LASTEXITCODE -ne 0) { exit 1 }
2929

3030
Pop-Location
3131
}
3232

3333
foreach ($test in ls test/*.Tests) {
3434
Push-Location $test
3535

36-
echo "build: Testing project in $test"
36+
echo "build: Testing project in $test"
3737

3838
& dotnet test -c Release
3939
if($LASTEXITCODE -ne 0) { exit 3 }

LICENSE

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
Apache License
23
Version 2.0, January 2004
34
http://www.apache.org/licenses/
@@ -178,15 +179,15 @@
178179
APPENDIX: How to apply the Apache License to your work.
179180

180181
To apply the Apache License to your work, attach the following
181-
boilerplate notice, with the fields enclosed by brackets "{}"
182+
boilerplate notice, with the fields enclosed by brackets "[]"
182183
replaced with your own identifying information. (Don't include
183184
the brackets!) The text should be enclosed in the appropriate
184185
comment syntax for the file format. We also recommend that a
185186
file or class name and description of purpose be included on the
186187
same "printed page" as the copyright notice for easier
187188
identification within third-party archives.
188189

189-
Copyright {yyyy} {name of copyright owner}
190+
Copyright [yyyy] [name of copyright owner]
190191

191192
Licensed under the Apache License, Version 2.0 (the "License");
192193
you may not use this file except in compliance with the License.

README.md

+28-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Serilog.Extensions.Logging.File [![NuGet Pre Release](https://img.shields.io/nuget/vpre/Serilog.Extensions.Logging.File.svg)](https://nuget.org/packages/Serilog.Extensions.Logging.File) [![Join the chat at https://gitter.im/serilog/serilog](https://img.shields.io/gitter/room/serilog/serilog.svg)](https://gitter.im/serilog/serilog) [![Build status](https://ci.appveyor.com/api/projects/status/rdff6bp9oeqfxif7?svg=true)](https://ci.appveyor.com/project/serilog/serilog-extensions-logging-file)
22

3-
This package makes it a one-liner - `loggerFactory.AddFile()` - to configure top-quality file logging for ASP.NET Core apps.
3+
This package makes it a one-liner - `loggingBuilder.AddFile()` - to configure top-quality file logging for ASP.NET Core apps.
44

55
* Text or JSON file output
66
* Files roll over on date; capped file size
77
* Request ids and event ids included with each message
8-
* Writes are performed on a background thread
8+
* Log writes are performed asynchronously
99
* Files are periodically flushed to disk (required for Azure App Service log collection)
1010
* Fast, stable, battle-proven logging code courtesy of [Serilog](https://serilog.net)
1111

@@ -16,21 +16,37 @@ You can get started quickly with this package, and later migrate to the full Ser
1616
**1.** Add [the NuGet package](https://nuget.org/packages/serilog.extensions.logging.file) as a dependency of your project either with the package manager or directly to the CSPROJ file:
1717

1818
```xml
19-
<PackageReference Include="Serilog.Extensions.Logging.File" Version="2.0.0" />
19+
<PackageReference Include="Serilog.Extensions.Logging.File" Version="3.0.0" />
2020
```
2121

22-
**2.** In your `Program` class, configure logging on the web host builder, and call `AddFile()` on the provided `loggingBuilder`.
22+
**2.** In your `Program` class, configure logging on the host builder, and call `AddFile()` on the provided `loggingBuilder`:
2323

2424
```csharp
25-
WebHost.CreateDefaultBuilder(args)
26-
.ConfigureLogging((hostingContext, builder) =>
25+
Host.CreateDefaultBuilder(args)
26+
.ConfigureWebHostDefaults(webHost =>
2727
{
28-
builder.AddFile("Logs/myapp-{Date}.txt");
28+
webHost.UseStartup<Startup>();
29+
})
30+
.ConfigureLogging((hostingContext, loggingBuilder) =>
31+
{
32+
loggingBuilder.AddFile("Logs/myapp-{Date}.txt");
2933
})
30-
.UseStartup<Startup>()
3134
.Build();
3235
```
3336

37+
Or, alternatively, with [Minimal APIs](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis):
38+
39+
```csharp
40+
var builder = WebApplication.CreateBuilder(args);
41+
42+
builder.Logging.AddFile("Logs/myapp-{Date}.txt");
43+
// Add other services to the container.
44+
<...>
45+
46+
var app = builder.Build();
47+
<...>
48+
```
49+
3450
**Done!** The framework will inject `ILogger` instances into controllers and other classes:
3551

3652
```csharp
@@ -144,7 +160,7 @@ In `appsettings.json` add a `"Logging"` property:
144160
And then pass the configuration section to the `AddFile()` method:
145161

146162
```csharp
147-
loggingBuilder.AddFile(Configuration.GetSection("Logging"));
163+
loggingBuilder.AddFile(hostingContext.Configuration.GetSection("Logging"));
148164
```
149165

150166
In addition to the properties shown above, the `"Logging"` configuration supports:
@@ -160,12 +176,12 @@ In addition to the properties shown above, the `"Logging"` configuration support
160176

161177
This package is opinionated, providing the most common/recommended options supported by Serilog. For more sophisticated configuration, using Serilog directly is recommened. See the instructions in [Serilog.AspNetCore](https://github.com/serilog/serilog-aspnetcore) to get started.
162178

163-
The following packages are used to provide `AddFile()`:
179+
The following packages are used to provide `loggingBuilder.AddFile()`:
164180

165181
* [Serilog](https://github.com/serilog/serilog) - the core logging pipeline
166-
* [Serilog.Sinks.RollingFile](https://github.com/serilog/serilog-sinks-rollingfile) - rolling file output
167182
* [Serilog.Formatting.Compact](https://github.com/serilog/serilog-formatting-compact) - JSON event formatting
168183
* [Serilog.Extensions.Logging](https://github.com/serilog/serilog-extensions-logging) - ASP.NET Core integration
169-
* [Serilog.Sinks.Async](https://github.com/serilog/serilog-sinks-async) - async wrapper to perform log writes on a background thread
184+
* [Serilog.Sinks.Async](https://github.com/serilog/serilog-sinks-async) - wrapper to perform log writes asynchronously
185+
* [Serilog.Sinks.RollingFile](https://github.com/serilog/serilog-sinks-rollingfile) - rolling file output
170186

171187
If you decide to switch to the full Serilog API and need help, please drop into the [Gitter channel](https://gitter.im/serilog/serilog) or post your question on [Stack Overflow](http://stackoverflow.com/questions/tagged/serilog).

appveyor.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: '{build}'
22
skip_tags: true
3-
image: Visual Studio 2017
3+
image: Visual Studio 2022
44
configuration: Release
55
test: off
66
build_script:
@@ -10,14 +10,14 @@ artifacts:
1010
deploy:
1111
- provider: NuGet
1212
api_key:
13-
secure: T+8ZvBlF6teDbEuPRHVWMkuaU84MAygeuveqR4TqHbcBrW7bBOhtljzUNfiLYjfr
13+
secure: UxWT5mmjtRUP+5inaZmM2L9cCnqjcoLZpWUMeWR2+f6CG8ERDRu0FLBIL1Ea8+hr
1414
skip_symbols: true
1515
on:
16-
branch: /^(master|dev)$/
16+
branch: /^(main|dev)$/
1717
- provider: GitHub
1818
auth_token:
1919
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
2020
artifact: /Serilog.*\.nupkg/
2121
tag: v$(appveyor_build_version)
2222
on:
23-
branch: master
23+
branch: main

assets/serilog-extension-nuget.png

21.9 KB
Loading

example/WebApplication/WebApplication.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</ItemGroup>
1414

1515
<ItemGroup>
16-
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
16+
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
1717
</ItemGroup>
1818

1919
</Project>

serilog-extensions-logging-file.sln

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26430.14
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.32014.148
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0069BFD6-B0EE-4204-A85F-F75E31A77B3C}"
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "global", "global", "{B0D573D8-1AE2-4C5C-817A-95815067452E}"
99
ProjectSection(SolutionItems) = preProject
10+
.gitattributes = .gitattributes
11+
.gitignore = .gitignore
1012
appveyor.yml = appveyor.yml
1113
Build.ps1 = Build.ps1
1214
LICENSE = LICENSE
@@ -50,4 +52,7 @@ Global
5052
{E640A22A-DF3C-40A2-AC72-DEB2F9B16241} = {0069BFD6-B0EE-4204-A85F-F75E31A77B3C}
5153
{64A3F2C5-D71E-44A6-8DC7-99474765B32E} = {D54DE844-AC36-4872-928F-5F573D41ACAE}
5254
EndGlobalSection
55+
GlobalSection(ExtensibilityGlobals) = postSolution
56+
SolutionGuid = {4A37A10E-F9A2-4578-9B58-EB7C07B64E66}
57+
EndGlobalSection
5358
EndGlobal

src/Serilog.Extensions.Logging.File/Microsoft/Extensions/Logging/FileLoggerExtensions.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using Microsoft.Extensions.Configuration;
45
using Serilog;
56
using Serilog.Debugging;
67
using Serilog.Extensions.Logging.File;
7-
using System.Linq;
8+
using Serilog.Formatting;
89
using Serilog.Formatting.Compact;
910
using Serilog.Formatting.Display;
10-
using Serilog.Formatting;
1111

1212
namespace Microsoft.Extensions.Logging
1313
{
@@ -44,7 +44,7 @@ public static ILoggerFactory AddFile(this ILoggerFactory loggerFactory, IConfigu
4444
/// Adds a file logger initialized from the supplied configuration section.
4545
/// </summary>
4646
/// <param name="loggerFactory">The logger factory.</param>
47-
/// <param name="pathFormat">Filname to write. The filename may include {Date} to specify how the date portion of the
47+
/// <param name="pathFormat">Filname to write. The filename may include {Date} to specify how the date portion of the
4848
/// filename is calculated. May include environment variables.</param>
4949
/// <param name="minimumLevel">The level below which events will be suppressed (the default is <see cref="LogLevel.Information"/>).</param>
5050
/// <param name="levelOverrides">A dictionary mapping logger name prefixes to minimum logging levels.</param>
@@ -98,7 +98,7 @@ public static ILoggingBuilder AddFile(this ILoggingBuilder loggingBuilder, IConf
9898
/// Adds a file logger initialized from the supplied configuration section.
9999
/// </summary>
100100
/// <param name="loggingBuilder">The logging builder.</param>
101-
/// <param name="pathFormat">Filname to write. The filename may include {Date} to specify how the date portion of the
101+
/// <param name="pathFormat">Filname to write. The filename may include {Date} to specify how the date portion of the
102102
/// filename is calculated. May include environment variables.</param>
103103
/// <param name="minimumLevel">The level below which events will be suppressed (the default is <see cref="LogLevel.Information"/>).</param>
104104
/// <param name="levelOverrides">A dictionary mapping logger name prefixes to minimum logging levels.</param>
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<Description>Add file logging to ASP.NET Core apps with one line of code.</Description>
5-
<VersionPrefix>2.0.0</VersionPrefix>
5+
<VersionPrefix>3.0.0</VersionPrefix>
66
<Authors>Serilog Contributors</Authors>
7-
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
7+
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
88
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
99
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1010
<AssemblyName>Serilog.Extensions.Logging.File</AssemblyName>
@@ -13,9 +13,9 @@
1313
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
1414
<PackageId>Serilog.Extensions.Logging.File</PackageId>
1515
<PackageTags>asp.net;core;logging;file</PackageTags>
16-
<PackageIconUrl>http://serilog.net/images/serilog-extension-nuget.png</PackageIconUrl>
16+
<PackageIcon>serilog-extension-nuget.png</PackageIcon>
17+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1718
<PackageProjectUrl>https://github.com/serilog/serilog-extensions-logging-file</PackageProjectUrl>
18-
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
1919
<RepositoryUrl>https://github.com/serilog/serilog-extensions-logging-file</RepositoryUrl>
2020
<RepositoryType>git</RepositoryType>
2121
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
@@ -25,13 +25,36 @@
2525
</PropertyGroup>
2626

2727
<ItemGroup>
28-
<PackageReference Include="Serilog" Version="2.5.0" />
28+
<None Include="../../assets/serilog-extension-nuget.png" Pack="true" PackagePath="" />
29+
<None Include="../../LICENSE" Pack="true" PackagePath="" />
30+
</ItemGroup>
31+
32+
<ItemGroup>
33+
<PackageReference Include="Serilog" Version="2.10.0" />
34+
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
2935
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
30-
<PackageReference Include="Serilog.Formatting.Compact" Version="1.0.0" />
31-
<PackageReference Include="Serilog.Extensions.Logging" Version="2.0.2" />
32-
<PackageReference Include="Serilog.Sinks.Async" Version="1.1.0" />
33-
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.0.0" />
34-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.0.0" />
36+
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
37+
<PackageReference Include="Serilog.Formatting.Compact" Version="1.1.0" />
38+
</ItemGroup>
39+
40+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
41+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.2.0" />
42+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.2.4" />
43+
</ItemGroup>
44+
45+
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
46+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.22" />
47+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.1.22" />
48+
</ItemGroup>
49+
50+
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
51+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
52+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="5.0.0" />
53+
</ItemGroup>
54+
55+
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
56+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
57+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
3558
</ItemGroup>
3659

3760
</Project>
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
4+
<TargetFrameworks>net48;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
55
<AssemblyName>Serilog.Extensions.Logging.File.Tests</AssemblyName>
66
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
77
<SignAssembly>true</SignAssembly>
88
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
99
<PackageId>Serilog.Extensions.Logging.File.Tests</PackageId>
1010
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
11-
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dnxcore50;portable-net45+win8</PackageTargetFallback>
12-
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">1.0.4</RuntimeFrameworkVersion>
1311
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
1412
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
1513
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
@@ -20,9 +18,9 @@
2018
</ItemGroup>
2119

2220
<ItemGroup>
23-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
24-
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
25-
<PackageReference Include="xunit" Version="2.2.0" />
21+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.*" />
22+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
23+
<PackageReference Include="xunit" Version="2.4.1" />
2624
</ItemGroup>
2725

2826
</Project>

0 commit comments

Comments
 (0)