-
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 #83 from gertjvr/dev
Adding netstandard 2.0 logging abstraction support
- Loading branch information
Showing
5 changed files
with
65 additions
and
9 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,5 +1,5 @@ | ||
{ | ||
"sdk": { | ||
"version": "1.0.3" | ||
"version": "2.0.0-preview2-006497" | ||
} | ||
} | ||
} |
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
33 changes: 33 additions & 0 deletions
33
src/Serilog.Extensions.Logging/SerilogLoggerServicesExtensions.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
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. | ||
/// </summary> | ||
public static class SerilogLoggerServicesExtensions | ||
{ | ||
/// <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="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) | ||
{ | ||
if (services == null) throw new ArgumentNullException(nameof(services)); | ||
|
||
services.AddLogging(builder => builder.AddProvider(new SerilogLoggerProvider(logger, dispose))); | ||
|
||
return services; | ||
} | ||
} | ||
} |