Skip to content

Commit e8e4a3e

Browse files
authored
Merge pull request #135 from serilog/dev
2.0.3 Release
2 parents 8cf5db7 + 5a8be58 commit e8e4a3e

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
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+
### .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
```

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ artifacts:
1616
deploy:
1717
- provider: NuGet
1818
api_key:
19-
secure: nvZ/z+pMS91b3kG4DgfES5AcmwwGoBYQxr9kp4XiJHj25SAlgdIxFx++1N0lFH2x
19+
secure: bd9z4P73oltOXudAjPehwp9iDKsPtC+HbgshOrSgoyQKr5xVK+bxJQngrDJkHdY8
2020
skip_symbols: true
2121
on:
2222
branch: /^(master|dev)$/

src/Serilog.Extensions.Logging/Serilog.Extensions.Logging.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<Description>Low-level Serilog provider for Microsoft.Extensions.Logging</Description>
5-
<VersionPrefix>2.0.2</VersionPrefix>
5+
<VersionPrefix>2.0.3</VersionPrefix>
66
<Authors>Microsoft;Serilog Contributors</Authors>
77
<TargetFrameworks>net45;net46;net461;netstandard1.3;netstandard2.0</TargetFrameworks>
88
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -16,6 +16,8 @@
1616
<PackageIconUrl>http://serilog.net/images/serilog-extension-nuget.png</PackageIconUrl>
1717
<PackageProjectUrl>https://github.com/serilog/serilog-extensions-logging</PackageProjectUrl>
1818
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
19+
<RepositoryUrl>https://github.com/serilog/serilog-extensions-logging</RepositoryUrl>
20+
<RepositoryType>git</RepositoryType>
1921
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
2022
<RootNamespace>Serilog</RootNamespace>
2123
</PropertyGroup>
@@ -29,7 +31,7 @@
2931
</ItemGroup>
3032

3133
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' or '$(TargetFramework)' == 'netstandard2.0' ">
32-
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
34+
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.*" />
3335
</ItemGroup>
3436

3537
<PropertyGroup Condition=" '$(TargetFramework)' == 'net46' ">

src/Serilog.Extensions.Logging/SerilogLoggingBuilderExtensions.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#if LOGGING_BUILDER
1616

1717
using System;
18+
using Microsoft.Extensions.DependencyInjection;
1819
using Microsoft.Extensions.Logging;
1920
using Serilog.Extensions.Logging;
2021

@@ -38,7 +39,15 @@ public static ILoggingBuilder AddSerilog(this ILoggingBuilder builder, ILogger l
3839
{
3940
if (builder == null) throw new ArgumentNullException(nameof(builder));
4041

41-
builder.AddProvider(new SerilogLoggerProvider(logger, dispose));
42+
if (dispose)
43+
{
44+
builder.Services.AddSingleton<ILoggerProvider, SerilogLoggerProvider>(services => new SerilogLoggerProvider(logger, true));
45+
}
46+
else
47+
{
48+
builder.AddProvider(new SerilogLoggerProvider(logger));
49+
}
50+
4251
builder.AddFilter<SerilogLoggerProvider>(null, LogLevel.Trace);
4352

4453
return builder;

0 commit comments

Comments
 (0)