Skip to content

Commit d474914

Browse files
authored
Add CloseAndFlush() to example [Skip CI]
1 parent 1332279 commit d474914

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ call `AddSerilog()` on the provided `loggerFactory`.
3838
```csharp
3939
public void Configure(IApplicationBuilder app,
4040
IHostingEnvironment env,
41-
ILoggerFactory loggerfactory)
41+
ILoggerFactory loggerfactory,
42+
IApplicationLifetime appLifetime)
4243
{
4344
loggerfactory.AddSerilog();
45+
46+
// Ensure any buffered events are sent at shutdown
47+
appLifetime.ApplicationStopped.Register(Log.CloseAndFlush);
4448
```
4549

4650
That's it! With the level bumped up a little you should see log output like:

0 commit comments

Comments
 (0)