diff --git a/README.md b/README.md
index e67fe4a..fe2934f 100644
--- a/README.md
+++ b/README.md
@@ -5,9 +5,9 @@ A Serilog provider for [Microsoft.Extensions.Logging](https://www.nuget.org/pack
### ASP.NET Core 2.0+ Instructions
-ASP.NET Core 2.0 applications should prefer [Serilog.AspNetCore](https://github.com/serilog/serilog-aspnetcore) and `UseSerilog()` instead.
+**ASP.NET Core 2.0** applications should prefer [Serilog.AspNetCore](https://github.com/serilog/serilog-aspnetcore) and `UseSerilog()` instead.
-### ASP.NET Core 1.0, 1.1, and Default Provider Integration
+### .NET Core 1.0, 1.1 and Default Provider Integration
The package implements `AddSerilog()` on `ILoggingBuilder` and `ILoggerFactory` to enable the Serilog provider under the default _Microsoft.Extensions.Logging_ implementation.
@@ -35,7 +35,7 @@ public class Startup
// Other startup code
```
-**Finally**, in your `Startup` class's `Configure()` method, remove the existing logger configuration entries and
+**Finally, for .NET Core 2.0+**, in your `Startup` class's `Configure()` method, remove the existing logger configuration entries and
call `AddSerilog()` on the provided `loggingBuilder`.
```csharp
@@ -48,6 +48,20 @@ call `AddSerilog()` on the provided `loggingBuilder`.
}
```
+**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`.
+
+```
+ public void Configure(IApplicationBuilder app,
+ IHostingEnvironment env,
+ ILoggerFactory loggerfactory,
+ IApplicationLifetime appLifetime)
+ {
+ loggerfactory.AddSerilog();
+
+ // Ensure any buffered events are sent at shutdown
+ appLifetime.ApplicationStopped.Register(Log.CloseAndFlush);
+```
+
That's it! With the level bumped up a little you should see log output like:
```
diff --git a/appveyor.yml b/appveyor.yml
index 2a0d6a6..0f0fb46 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -16,7 +16,7 @@ artifacts:
deploy:
- provider: NuGet
api_key:
- secure: nvZ/z+pMS91b3kG4DgfES5AcmwwGoBYQxr9kp4XiJHj25SAlgdIxFx++1N0lFH2x
+ secure: bd9z4P73oltOXudAjPehwp9iDKsPtC+HbgshOrSgoyQKr5xVK+bxJQngrDJkHdY8
skip_symbols: true
on:
branch: /^(master|dev)$/
diff --git a/src/Serilog.Extensions.Logging/Serilog.Extensions.Logging.csproj b/src/Serilog.Extensions.Logging/Serilog.Extensions.Logging.csproj
index 8773bb4..c2b5ba0 100644
--- a/src/Serilog.Extensions.Logging/Serilog.Extensions.Logging.csproj
+++ b/src/Serilog.Extensions.Logging/Serilog.Extensions.Logging.csproj
@@ -2,7 +2,7 @@
Low-level Serilog provider for Microsoft.Extensions.Logging
- 2.0.2
+ 2.0.3
Microsoft;Serilog Contributors
net45;net46;net461;netstandard1.3;netstandard2.0
true
@@ -16,6 +16,8 @@
http://serilog.net/images/serilog-extension-nuget.png
https://github.com/serilog/serilog-extensions-logging
http://www.apache.org/licenses/LICENSE-2.0
+ https://github.com/serilog/serilog-extensions-logging
+ git
false
Serilog
@@ -29,7 +31,7 @@
-
+
diff --git a/src/Serilog.Extensions.Logging/SerilogLoggingBuilderExtensions.cs b/src/Serilog.Extensions.Logging/SerilogLoggingBuilderExtensions.cs
index 701fa4c..d7a3f5f 100644
--- a/src/Serilog.Extensions.Logging/SerilogLoggingBuilderExtensions.cs
+++ b/src/Serilog.Extensions.Logging/SerilogLoggingBuilderExtensions.cs
@@ -15,6 +15,7 @@
#if LOGGING_BUILDER
using System;
+using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Serilog.Extensions.Logging;
@@ -38,7 +39,15 @@ public static ILoggingBuilder AddSerilog(this ILoggingBuilder builder, ILogger l
{
if (builder == null) throw new ArgumentNullException(nameof(builder));
- builder.AddProvider(new SerilogLoggerProvider(logger, dispose));
+ if (dispose)
+ {
+ builder.Services.AddSingleton(services => new SerilogLoggerProvider(logger, true));
+ }
+ else
+ {
+ builder.AddProvider(new SerilogLoggerProvider(logger));
+ }
+
builder.AddFilter(null, LogLevel.Trace);
return builder;