2

I looked at the Common.Logging Nuget Package and the latest version supports .NET Core 1. I am currently using .NET Core 3. Hence I am looking for recommendations, whether it is still a good idea to use Common.Logging NuGet package, or is there any other alternate I should explore.

I am writing a NuGet package and one of the requirement is that it can take any logging object, mostly Log4Net or NLog object and log everything according to their configurations, which would be passed in from the parent project.

Luke Girvin
  • 13,221
  • 9
  • 64
  • 84
jack
  • 321
  • 1
  • 5
  • 20
  • 1
    Your second requirement sounds like you need something called a Logging Facade: https://stackoverflow.com/questions/2733510/is-there-a-logging-facade-for-the-net-world – FarwoodHill Nov 18 '19 at 15:56
  • Why can I not use `Microsoft.Extensions.Logging` nuget package ? I think it does the same things ? – jack Nov 19 '19 at 15:43

2 Answers2

2

My suggestion here is that you don't re-invent the wheel and use the Microsoft.Extensions.Logging libraries that Microsoft is bringing to manage the logging providers from a single point.

You have already some third-party connectors for NLog and Log4Net that simplifies the way to log in multiple providers, just registering each at startup level.

HuorSwords
  • 2,225
  • 1
  • 21
  • 34
  • Thank you HuorSwords, I am using the Microsoft.Extensions.Logging and and it worked perfectly. I think you are the owner of the project and I have a suggestion for renaming the Microsoft.Extensions.Logging.Log4Net.AspNetCore to something else as it can be used with .net , .net standard and .net core. Just a suggestion. – jack Nov 25 '19 at 19:31
  • Not so trivial. :) At the beginning, the project itself just connects Microsoft.Extensions.Logging system with log4net on ASP.NET Core applications... but after some requests, the connector has been "evolved". It couldn't be renamed after published on Nuget.org without affecting the existing users. – HuorSwords Nov 26 '19 at 10:25
  • 1
    That makes total sense. Initially looking at the name I wasn't sure if this was the correct package to use or not – jack Dec 04 '19 at 17:16
0

I think it's pretty safe. The https://www.nuget.org/packages/Common.Logging.Core/3.4.1 is for .net standard 1.0 and it seems there was no need to update.

In addition, based in this request https://github.com/net-commons/common-logging/issues/148 the project is still active with plans to support in the future.

From this question Are there any alternatives to Common.Logging?, it seems that there are no other valid alternatives but use it, or go for a custom facade implementation.

Athanasios Kataras
  • 25,191
  • 4
  • 32
  • 61
  • Why can I not use `Microsoft.Extensions.Logging` nuget package ? I think it does the same things ? – jack Nov 19 '19 at 15:44