Removing Logging Abstractions from Libraries
I'm creating a library that uses a builder patter. I don't want the library to process exceptions, create logs, etc. I want the consumer to be able to decide how to handle this aspect. Normally I would just stick some Serilog inside but I don't to force the dependancy onto others. My first thought is to provide a Func<Exception> as an option in the builders pipeline. Currently this works fine and could certainly create extension motioned that plug serilog into this. The default output dumps the console if the WithLogging function is not provided. Where I don't love this, closures. I feel like generally consumers will create a closure with choose. I'm targeting dotnet6 for this project (for a few reasons).
6 Replies
this is why
ILogger
exists 🙂Damn now I feel dumb:) I thought that interface was part of asp, does it go back to standard 2.0?
Microsoft.Extensions.Logging.Abstractions 8.0.0
Logging abstractions for Microsoft.Extensions.Logging.
Commonly Used Types:
Microsoft.Extensions.Logging.ILogger
Microsoft.Extensions.Logging.ILoggerFactory
Microsoft.Extensions.Logging.ILogger
Microsoft.Extensions.Logging.LogLevel
Microsoft.Extensions.Logging.Logger
Microsoft.Extensions.Logging.LoggerMessage
Microsoft.Extensions.Logging.Abstra...
nice, thanks!
i think this cover the cases..