Common.Logging / Common.Logging.Core (last released 2017, effectively abandoned) is being
flagged by Dependabot and is a transitive source of ambiguity with the log4net ecosystem.
Replace with Microsoft.Extensions.Logging.Abstractions (MEL), the modern .NET standard.
[All src/ code]
→ com.espertech.esper.compat.logging.ILog (NEsper's own interface, NEsper.Compat)
→ com.espertech.esper.compat.logging.LogManager (NEsper's own factory, NEsper.Compat)
↓ default factory wires to:
→ LogCommon (wraps Common.Logging.ILog) (NEsper.Compat) ← REMOVE
↓ which wraps:
→ Common.Logging.ILog / LogManager (external) ← REMOVE
[NEsper.Log.NLog]
→ LoggerNLog.Register() rewires LogManager.Factory → LoggerNLog (wraps NLog.ILogger)
→ When registered, Common.Logging is bypassed entirely at runtime
[All src/ code]
→ com.espertech.esper.compat.logging.ILog (unchanged)
→ com.espertech.esper.compat.logging.LogManager (updated default factory)
↓ default factory wires to:
→ LogMEL (wraps Microsoft.Extensions.Logging.ILogger) ← NEW
↓ backed by:
→ ILoggerFactory (settable; defaults to NullLoggerFactory.Instance)
[NEsper.Log.NLog]
→ LoggerNLog.Register() unchanged — still rewires LogManager factories
| File | Type |
|---|---|
src/NEsper.Common/.../VariableUtil.cs |
using Common.Logging; + LogManager.GetLogger |
src/NEsper.Runtime/.../TimerUnitMultiple.cs |
using Common.Logging; + LogManager.GetLogger |
tst/NEsper.Regression/.../MultithreadFireAndForgetIndex.cs |
using Common.Logging; |
Note: All other tst/ hits for Common.Logging are configuration.Common.Logging (NEsper's
own config object — unrelated to the package).
- Map shim architecture (
ILog,LogCommon,LogManager,LoggerNLog) - Identify all direct
Common.Loggingpackage imports acrosssrc/andtst/ - Confirm
tst/false positives (configuration.Common.Loggingis NEsper config, not the package) - Record findings in this document
- Add
Microsoft.Extensions.Logging.AbstractionstoNEsper.Compat.csproj - Remove
Common.LoggingandCommon.Logging.CorefromNEsper.Compat.csproj - Delete
LogCommon.cs(wrapsCommon.Logging.ILog— no longer needed) - Create
LogMEL.cs— implementsILogby wrappingMicrosoft.Extensions.Logging.ILogger- MapFatal/IsFatalEnabled→LogLevel.Critical(MEL has no Fatal) - Rewrite
LogManager.cs— replace static constructor default factory: - Hold a settableILoggerFactory(default:NullLoggerFactory.Instance) -FactoryLoggerFromType/FactoryLoggerFromNamedelegates remain unchanged in signature
-
VariableUtil.cs— removeusing Common.Logging;, qualify tocompat.logging.LogManager -
TimerUnitMultiple.cs— same fix -
MultithreadFireAndForgetIndex.cs(tst) — removeusing Common.Logging;, fix reference
- Remove
Common.Logging3.4.1 andCommon.Logging.Core3.4.1 fromNEsper.Common.csproj(were already redundant; after Phase 2 they no longer exist anywhere)
-
LoggerNLog.Register()already works unchanged — no functional change required - Optionally add
NLog.Extensions.Loggingto enable MELILoggerFactoryintegration pattern
-
dotnet build NEsperAll.sln— zero errors -
dotnet list NEsperAll.sln package --include-transitive | Select-String "Common.Logging"— empty - Run
NEsper.Compat.Tests,NEsper.Common.Tests,NEsper.Runtime.Tests
- Stage all changes and commit with descriptive message
| Item | Risk | Mitigation |
|---|---|---|
IsFatalEnabled / Fatal() |
Medium — MEL has no Fatal level | Map to LogLevel.Critical in LogMEL |
LogManager static init |
Low — factory delegates replaceable by design | Default to NullLoggerFactory (safe no-op) |
2 direct Common.Logging imports in src/ |
Low — trivial using swap, API identical |
Covered in Phase 3 |
1 direct Common.Logging import in tst/ |
Low | Covered in Phase 3 |
LoggerNLog.Register() callers |
None — no signature change | No callers need updating |