Skip to content

Commit 85612f6

Browse files
authored
Show .NET Core 1.0/1.1 example in README [Skip CI]
Fixes #109.
1 parent d29a1b6 commit 85612f6

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ A Serilog provider for [Microsoft.Extensions.Logging](https://www.nuget.org/pack
55

66
### ASP.NET Core 2.0+ Instructions
77

8-
ASP.NET Core 2.0 applications should prefer [Serilog.AspNetCore](https://github.com/serilog/serilog-aspnetcore) and `UseSerilog()` instead.
8+
**ASP.NET Core 2.0 applications should prefer [Serilog.AspNetCore](https://github.com/serilog/serilog-aspnetcore) and `UseSerilog()` instead.**
99

10-
### ASP.NET Core 1.0, 1.1, and Default Provider Integration
10+
### ASP.NET Core 1.0, 1.1 and Default Provider Integration
1111

1212
The package implements `AddSerilog()` on `ILoggingBuilder` and `ILoggerFactory` to enable the Serilog provider under the default _Microsoft.Extensions.Logging_ implementation.
1313

@@ -35,7 +35,7 @@ public class Startup
3535
// Other startup code
3636
```
3737

38-
**Finally**, in your `Startup` class's `Configure()` method, remove the existing logger configuration entries and
38+
**Finally, for .NET Core 2.0+**, in your `Startup` class's `Configure()` method, remove the existing logger configuration entries and
3939
call `AddSerilog()` on the provided `loggingBuilder`.
4040

4141
```csharp
@@ -48,6 +48,20 @@ call `AddSerilog()` on the provided `loggingBuilder`.
4848
}
4949
```
5050

51+
**For .NET Core 1.0 or 1.1**, in your `Startup` class's `Configure()` method, remove the existing logger configuration entries and call `AddSerilog()` on the provided `loggerFactory`.
52+
53+
```
54+
public void Configure(IApplicationBuilder app,
55+
IHostingEnvironment env,
56+
ILoggerFactory loggerfactory,
57+
IApplicationLifetime appLifetime)
58+
{
59+
loggerfactory.AddSerilog();
60+
61+
// Ensure any buffered events are sent at shutdown
62+
appLifetime.ApplicationStopped.Register(Log.CloseAndFlush);
63+
```
64+
5165
That's it! With the level bumped up a little you should see log output like:
5266

5367
```

0 commit comments

Comments
 (0)