Skip to content

Commit 16be480

Browse files
authored
Merge pull request #202 from serilog/dev
3.4.0 Release
2 parents 210a242 + d05c38c commit 16be480

19 files changed

+295
-62
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: Bug report
3+
about: Report a bug and help us to improve Serilog
4+
title: ''
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
The Serilog maintainers want you to have a great experience using Serilog, and will happily track down and resolve bugs. We all have limited time, though, so please think through all of the factors that might be involved and include as much useful information as possible 😊.
11+
12+
ℹ If the problem is caused by a sink or other related package, please try to track down the correct repository for that package and create the report there: this tracker is for the **Serilog.AspNetCore** package only.
13+
14+
**Description**
15+
What's going wrong?
16+
17+
**Reproduction**
18+
Please provide code samples showing how you're configuring and calling Serilog to produce the behavior.
19+
20+
**Expected behavior**
21+
A concise description of what you expected to happen.
22+
23+
**Relevant package, tooling and runtime versions**
24+
What Serilog version are you using, on what platform?
25+
26+
**Additional context**
27+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an improvement to Serilog
4+
title: ''
5+
labels: enhancement
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/ISSUE_TEMPLATE/usage-help.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: Usage help
3+
about: Get help with using Serilog
4+
title: ''
5+
labels: invalid
6+
assignees: ''
7+
8+
---
9+
10+
Hi! 👋
11+
12+
The Serilog community wants you to have a great experience using Serilog. Unfortunately, only a handful of maintainers actively follow this repository, and our time is short, so we cannot answer usage questions posted here.
13+
14+
Fortunately, a much larger group of people (including some of us) also watch and answer questions on the [`serilog` tag on Stack Overflow](https://stackoverflow.com/questions/tagged/serilog).
15+
16+
Please head over to Stack Overflow, ask your question, and tag it with `serilog`. Thanks! ❤

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class Program
3131
try
3232
{
3333
Log.Information("Starting web host");
34-
CreateWebHostBuilder(args).Build().Run();
34+
CreateHostBuilder(args).Build().Run();
3535
return 0;
3636
}
3737
catch (Exception ex)
@@ -46,21 +46,22 @@ public class Program
4646
}
4747
```
4848

49-
**Then**, add `UseSerilog()` to the web host builder in `BuildWebHost()`.
49+
**Then**, add `UseSerilog()` to the Generic Host in `CreateHostBuilder()`.
5050

5151
```csharp
52-
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
53-
WebHost.CreateDefaultBuilder(args)
54-
.UseStartup<Startup>()
55-
.UseSerilog(); // <-- Add this line;
52+
public static IHostBuilder CreateHostBuilder(string[] args) =>
53+
Host.CreateDefaultBuilder(args)
54+
.UseSerilog() // <-- Add this line
55+
.ConfigureWebHostDefaults(webBuilder =>
56+
{
57+
webBuilder.UseStartup<Startup>();
58+
});
5659
}
5760
```
5861

5962
**Finally**, clean up by removing the remaining configuration for the default logger:
6063

61-
* Remove calls to `AddLogging()`
6264
* Remove the `"Logging"` section from _appsettings.json_ files (this can be replaced with [Serilog configuration](https://github.com/serilog/serilog-settings-configuration) as shown in [the _EarlyInitializationSample_ project](https://github.com/serilog/serilog-aspnetcore/blob/dev/samples/EarlyInitializationSample/Program.cs), if required)
63-
* Remove `ILoggerFactory` parameters and any `Add*()` calls on the logger factory in _Startup.cs_
6465
* Remove `UseApplicationInsights()` (this can be replaced with the [Serilog AI sink](https://github.com/serilog/serilog-sinks-applicationinsights), if required)
6566

6667
That's it! With the level bumped up a little you will see log output resembling:
@@ -191,13 +192,13 @@ app.UseSerilogRequestLogging(options =>
191192
You can alternatively configure Serilog inline, in `BuildWebHost()`, using a delegate as shown below:
192193

193194
```csharp
194-
.UseSerilog((hostingContext, loggerConfiguration) => loggerConfiguration
195+
.UseSerilog((hostingContext, services, loggerConfiguration) => loggerConfiguration
195196
.ReadFrom.Configuration(hostingContext.Configuration)
196197
.Enrich.FromLogContext()
197198
.WriteTo.Console())
198199
```
199200

200-
This has the advantage of making the `hostingContext`'s `Configuration` object available for [configuration of the logger](https://github.com/serilog/serilog-settings-configuration), but at the expense of losing `Exception`s raised earlier in program startup.
201+
This has the advantage of making a service provider and the `hostingContext`'s `Configuration` object available for [configuration of the logger](https://github.com/serilog/serilog-settings-configuration), but at the expense of losing `Exception`s raised earlier in program startup.
201202

202203
If this method is used, `Log.Logger` is assigned implicitly, and closed when the app is shut down.
203204

appveyor.yml

Lines changed: 3 additions & 3 deletions
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 2019
44
install:
55
- ps: ./Setup.ps1
66
build_script:
@@ -10,9 +10,9 @@ artifacts:
1010
- path: artifacts/Serilog.*.nupkg
1111
deploy:
1212
- provider: NuGet
13-
api_key:
14-
secure: gvYNwOSxj9Bq4erOm7alpWzHlEmNLLUV99VYKV1WF9qTJeDkvYpswoNHi9sAlZH4
1513
skip_symbols: true
14+
api_key:
15+
secure: jZtLAmD4ALF9x1BZR1DiV3KhKlliWbzRUAw73xfMZaBsvz19123qLz2zw1+hPdcn
1616
on:
1717
branch: /^(master|dev)$/
1818
- provider: GitHub

global.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"sdk": {
3-
"version": "3.0.100"
3+
"allowPrerelease": false,
4+
"version": "3.1.201",
5+
"rollForward": "latestFeature"
46
}
5-
}
7+
}

samples/EarlyInitializationSample/EarlyInitializationSample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.0</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>

samples/InlineInitializationSample/InlineInitializationSample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.0</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>

samples/InlineInitializationSample/Program.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ public static void Main(string[] args)
1313

1414
public static IHostBuilder CreateHostBuilder(string[] args) =>
1515
Host.CreateDefaultBuilder(args)
16-
.ConfigureWebHostDefaults(webBuilder =>
17-
{
18-
webBuilder.UseStartup<Startup>();
19-
})
20-
.UseSerilog((hostingContext, loggerConfiguration) => loggerConfiguration
16+
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>())
17+
.UseSerilog((hostingContext, services, loggerConfiguration) => loggerConfiguration
2118
.ReadFrom.Configuration(hostingContext.Configuration)
2219
.Enrich.FromLogContext()
2320
.WriteTo.Debug()

samples/InlineInitializationSample/Startup.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1-
using System.Net;
21
using Microsoft.AspNetCore.Builder;
32
using Microsoft.AspNetCore.Hosting;
43
using Microsoft.Extensions.DependencyInjection;
54
using Microsoft.Extensions.Hosting;
65
using Serilog;
7-
using Serilog.Events;
6+
using Serilog.AspNetCore;
87

98
namespace InlineInitializationSample
109
{
1110
public class Startup
1211
{
1312
public void ConfigureServices(IServiceCollection services)
1413
{
14+
services.Configure<RequestLoggingOptions>(o =>
15+
{
16+
o.EnrichDiagnosticContext = (diagnosticContext, httpContext) =>
17+
{
18+
diagnosticContext.Set("RemoteIpAddress", httpContext.Connection.RemoteIpAddress.MapToIPv4());
19+
};
20+
});
21+
1522
services.AddControllersWithViews();
1623
}
1724

0 commit comments

Comments
 (0)