-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from gertjvr/dev
Extends ILoggerBuilder this resolves #84
- Loading branch information
Showing
8 changed files
with
43 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net46;netcoreapp1.0</TargetFrameworks> | ||
<TargetFrameworks>net46;netcoreapp2.0</TargetFrameworks> | ||
<AssemblyName>Sample</AssemblyName> | ||
<OutputType>Exe</OutputType> | ||
<PackageId>Sample</PackageId> | ||
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">1.0.4</RuntimeFrameworkVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Serilog.Extensions.Logging\Serilog.Extensions.Logging.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0-preview2-final" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0-preview2-final" /> | ||
<PackageReference Include="Serilog.Sinks.Literate" Version="2.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.0.2" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' "> | ||
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' "> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition=" '$(TargetFramework)' == 'net46' "> | ||
<Reference Include="System" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
</ItemGroup> | ||
|
||
</Project> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 6 additions & 10 deletions
16
...ogging/SerilogLoggerServicesExtensions.cs → ...ogging/SerilogLoggingBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,29 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
using Serilog.Extensions.Logging; | ||
|
||
|
||
namespace Serilog | ||
{ | ||
/// <summary> | ||
/// Extends <see cref="IServiceCollection"/> with Serilog configuration methods. | ||
/// Extends <see cref="ILoggingBuilder"/> with Serilog configuration methods. | ||
/// </summary> | ||
public static class SerilogLoggerServicesExtensions | ||
public static class SerilogLoggingBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Add Serilog to the logging pipeline. | ||
/// </summary> | ||
/// <param name="services">The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> to add services to.</param> | ||
/// <param name="builder">The <see cref="T:Microsoft.Extensions.Logging.ILoggingBuilder" /> to add logging provider to.</param> | ||
/// <param name="logger">The Serilog logger; if not supplied, the static <see cref="Serilog.Log"/> will be used.</param> | ||
/// <param name="dispose">When true, dispose <paramref name="logger"/> when the framework disposes the provider. If the | ||
/// logger is not specified but <paramref name="dispose"/> is true, the <see cref="Log.CloseAndFlush()"/> method will be | ||
/// called on the static <see cref="Log"/> class instead.</param> | ||
/// <returns>The logger factory.</returns> | ||
public static IServiceCollection AddSerilog(this IServiceCollection services, Serilog.ILogger logger = null, bool dispose = false) | ||
public static void AddSerilog(this ILoggingBuilder builder, ILogger logger = null, bool dispose = false) | ||
{ | ||
if (services == null) throw new ArgumentNullException(nameof(services)); | ||
if (builder == null) throw new ArgumentNullException(nameof(builder)); | ||
|
||
services.AddLogging(builder => builder.AddProvider(new SerilogLoggerProvider(logger, dispose))); | ||
|
||
return services; | ||
builder.AddProvider(new SerilogLoggerProvider(logger, dispose)); | ||
} | ||
} | ||
} |