-
Notifications
You must be signed in to change notification settings - Fork 209
Expose SerilogLoggerFactory
#19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,26 +18,49 @@ | |
|
||
namespace Serilog.AspNetCore | ||
{ | ||
class SerilogLoggerFactory : ILoggerFactory | ||
/// <summary> | ||
/// Implements Microsoft's ILoggerFactory so that we can inject Serilog Logger. | ||
/// </summary> | ||
/// <seealso cref="Microsoft.Extensions.Logging.ILoggerFactory" /> | ||
public class SerilogLoggerFactory : ILoggerFactory | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation is funny here and below - may need to use spaces, rather than tabs? |
||
{ | ||
readonly SerilogLoggerProvider _provider; | ||
|
||
public SerilogLoggerFactory(Serilog.ILogger logger = null, bool dispose = false) | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SerilogLoggerFactory"/> class. | ||
/// </summary> | ||
/// <param name="logger">The logger.</param> | ||
/// <param name="dispose">if set to <c>true</c> [dispose].</param> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could use the same documentation here as in https://github.com/serilog/serilog-aspnetcore/blob/dev/src/Serilog.AspNetCore/SerilogWebHostBuilderExtensions.cs#L33 |
||
public SerilogLoggerFactory(Serilog.ILogger logger = null, bool dispose = false) | ||
{ | ||
_provider = new SerilogLoggerProvider(logger, dispose); | ||
} | ||
|
||
public void Dispose() | ||
/// <summary> | ||
/// Disposes the provider. | ||
/// </summary> | ||
public void Dispose() | ||
{ | ||
_provider.Dispose(); | ||
} | ||
|
||
public Microsoft.Extensions.Logging.ILogger CreateLogger(string categoryName) | ||
/// <summary> | ||
/// Creates a new <see cref="T:Microsoft.Extensions.Logging.ILogger" /> instance. | ||
/// </summary> | ||
/// <param name="categoryName">The category name for messages produced by the logger.</param> | ||
/// <returns> | ||
/// The <see cref="T:Microsoft.Extensions.Logging.ILogger" />. | ||
/// </returns> | ||
public Microsoft.Extensions.Logging.ILogger CreateLogger(string categoryName) | ||
{ | ||
return _provider.CreateLogger(categoryName); | ||
} | ||
|
||
public void AddProvider(ILoggerProvider provider) | ||
/// <summary> | ||
/// Adds an <see cref="T:Microsoft.Extensions.Logging.ILoggerProvider" /> to the logging system. | ||
/// </summary> | ||
/// <param name="provider">The <see cref="T:Microsoft.Extensions.Logging.ILoggerProvider" />.</param> | ||
public void AddProvider(ILoggerProvider provider) | ||
{ | ||
SelfLog.WriteLine("Ignoring added logger provider {0}", provider); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of
Microsoft's ILoggerFactory
we could use<see cref="ILoggerFactory"/>