DEV Community

loading...

Discussion on: log4net Tutorial - The Complete Guide for beginners and pros

Collapse
aregaz profile image
Illia Ratkevych

Thanks for the article, Thomas. I use log4net for a couple of years, with log4stash appender to write logs to Elasticsearch. It works pretty well, but I miss the support of native Microsoft.Extensions.Logging.ILogger in my codebase - we use our own wrapper around log4net.ILog interface.
Can log4net be used through native Microsoft.Extensions.Logging.ILogger interface? If so, what should I do with my custom properties which I add to almost every log message?

Collapse
thomasardal profile image
Thomas Ardal Author

Not sure exactly what you mean there. You want to use Microsoft.Extensions.Logging.ILogger as the main interface for logging messages. And then configure log4net as the implementation for that and control were to persist the log messages with log4net config?

Collapse
aregaz profile image
Illia Ratkevych

Yes, my goal is to use Microsoft.Extensions.Logging.ILogger everywhere in my solution. I would rather use Microsoft's interface ILogger than my own wrapper or directly log4net interface. Unfortunately, I haven't found any existed Microsoft.Extensions.Logging.ILogger implementation that uses log4net or any kind of adapter. Maybe I'm using old log4net nuget package and now they implement Microsoft's ILogger interface.

Thread Thread
thomasardal profile image
Thomas Ardal Author

You could use a NuGet package like this one: nuget.org/packages/Microsoft.Exten....

Thread Thread
aregaz profile image
Illia Ratkevych

😳how could I missed that?
Thank a lot!