-
Notifications
You must be signed in to change notification settings - Fork 61
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
Replace log4net with Microsoft.Extensions.Logging.Abstractions #103
Conversation
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.
Thank you for this PR. I like the fact that you replaced string formats by interpolated strings.
nitpick: The Log4NetConfigurator types were helpful to understand complex unit tests and they will be missed. Do you really think they should be removed?
|
||
namespace Abc.Zebus.Directory.Runner | ||
{ | ||
public sealed class Log4NetFactory : ILoggerFactory |
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.
You had to implement this? There is no built-in Log4NetLoggerFactory?
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.
log4net doesn't reference Microsoft.Extensions.Logging.Abstractions, so there's nothing built-in
src/Abc.Zebus.Persistence.Runner/Abc.Zebus.Persistence.Runner.csproj
Outdated
Show resolved
Hide resolved
{ | ||
private static ILoggerFactory _loggerFactory = NullLoggerFactory.Instance; | ||
|
||
public static ILoggerFactory LoggerFactory |
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.
question: Why did you choose to expose ILoggerFactory
and not ILoggerProvider
?
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.
ILoggerFactory
seemed to be the standard approach, and it's conceptually more high-level.
@ltrzesniewski |
I mentioned this in the issue:
The implementation in the package adds some overhead since it parses the string in order to convert it to an argument to |
# Conflicts: # src/Abc.Zebus.Persistence.Cassandra/Cql/CqlStorage.cs # src/Abc.Zebus.Persistence.Cassandra/Cql/PeerStateRepository.cs # src/Abc.Zebus.Persistence.Runner/Abc.Zebus.Persistence.Runner.csproj # src/Abc.Zebus.Persistence/Handlers/MessageHandledHandler.cs # src/Abc.Zebus.Persistence/Handlers/PersistMessageCommandHandler.cs # src/Abc.Zebus/Directory/PeerDirectoryClient.cs
This replaces log4net (which is dormant) with the Microsoft.Extensions.Logging.Abstractions package.
You now have to set the
ZebusLogManager.LoggerFactory
static property in order to get logs from Zebus. Further changes to this property will be picked up (which is how you can notifyBusMessageLogger
that the underlying logging configuration changed).Additional notes:
ILogger
using extension methods, but using the real API seemed cleaner.$"..."
) instead in order to avoid additional string parsing and impacting the formatter cache.ZebusLogManager.NotifyConfigurationChanged()
method in order to notifyBusMessageLogger
to reload its cache?