Registering in console apps and dotnet-core class libraries?
First of all, the introduction of Microsoft.Extensions.Logging needs clarification, I recommend reading this site https://msdn.microsoft.com/en-us/magazine/mt694089.aspx , which reads:
Logging? Why do we need a new logging system? We already have NLog, Log4Net, Loggr, Serilog and built-in Microsoft.Diagnostics.Trace / Debug / TraceSource, just to name a few.
...
Hence, you are probably tempted to write your own logging API wrapper that calls any particular logging framework that you or your company choose this week.
...
What Microsoft provides Microsoft.Extensions.Logging is a wrapper so everyone doesn't have to write their own.
Now there are some boot boxes that Microsoft sent, they are bugging here: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging#built-in-logging-providers
As you can see, many of the destinations do not exist, such as writing to a file.
Luckily for you and I, there are already some .Net logging implementations that use Microsoft.Extensions.Logging interfaces, such as ILogger. Some of them are bugging here: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging#third-party-logging-providers
If you are willing to bet on a different logging framework, I personally recommend a logging framework that provides structured logging, such as Serilog ( https://serilog.net/ ), which has built-in support for the new .Net Core logging interfaces.
Also, read this for the benefits of structured logging: https://softwareengineering.stackexchange.com/questions/312197/benefits-of-structured-logging-vs-basic-logging
EDIT: There is built-in .Net Core support for log4net using this NuGet package: https://www.nuget.org/packages/RobertHargreaves.log4net.Trunk/ To set it up with a config file, see this blog post: https://stackify.com/making-log4net-net-core-work/
It doesn't seem to have built-in support for the Ilogger and ILoggerFactory interfaces of the Microsoft.Extensions.Logging system.
source to share