A replacement for net-commons' Common Logging.
This project is born out of need here at AddUp's. We have a huge .NET 4.7.2-based codebase that quite heavily relies on Common.Logging; and we are currently in the process of migrating parts of this code to .NET 6. Although it would be possible and probably desirable to replace Common.Logging-based code by something else, for practical and non-regression purpose, it appears using a .NET 6-friendly port of Common.Logging is useful. Hence this project.
Although technically this is not a fork of https://github.com/net-commons/common-logging (because the original repository contains far too much code I don't want here), it aims at being nearly API-compatible with its inspiration.
Here are the main differences:
- Only .NET Standard 2.0 is targeted
- Packages, Assemblies and Namespaces are named
AddUp.CommonLogging.* - The two original
Common.Logging.CoreandCommon.Loggingpackages are merged into a uniqueAddUp.CommonLoggingpackage (and assembly) - For now, only NLog is supported (since version 4.5)
- Obsolete methods were removed
Using AddUp.CommonLogging is very similar to using Common.Logging. One mainly has to replace occurrences of Common.Logging by AddUp.CommonLogging both in C# source code and in App.config.
In libraries, instead of referencing the Common.Logging or Common.Logging.Core nuget packages, reference AddUp.CommonLogging.
In application code, given NLog is the concrete logging implementation, reference AddUp.CommonLogging.NLog instead of Common.Logging.NLog40 (or any other NLog-suffixed package).
A typical App.config file delegating logging to NLog would look like this (here again, Common.Logging is replaced by AddUp.CommonLogging be it in type or assembly names).
Also note that the section group should be addup and not common (so that it does not collide with eventual Common.Logging configuration):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="addup">
<section name="logging" type="AddUp.CommonLogging.ConfigurationSectionHandler, AddUp.CommonLogging" />
</sectionGroup>
</configSections>
<addup>
<logging>
<factoryAdapter type="AddUp.CommonLogging.NLog.NLogLoggerFactoryAdapter, AddUp.CommonLogging.NLog">
<arg key="configType" value="FILE" />
<arg key="configFile" value="~/nlog.config" />
</factoryAdapter>
</logging>
</addup>
</configuration>- Enabled multi-targeting:
netstandard2.0,net6.0andnet8.0. When targetingnet8.0,System.Configuration.ConfigurationManagerdependency version is8.0.0; otherwise,6.0.0. - Code Quality
- No change apart from the PDBs being included in the
nupkgfiles
- BUGFIX: the configuration section group name should be
addupand notcommon.
Initial version