NLog / NLog.Extensions.Logging

NLog as Logging Provider for Microsoft Extension Logging
https://nlog-project.org
BSD 2-Clause "Simplified" License
392 stars 151 forks source link

Please add a target for .NET 4.8 that targets newer Microsoft Libraries #740

Closed robotgryphon closed 6 months ago

robotgryphon commented 6 months ago

Type (choose one):

NLog version: 5.2.8 NLog.Extensions.Logging version: 5.x.x NLog.Web.AspNetCore version: not used Platform: .NET Framework 4.8


As the title states, right now if you use NLog.Extensions.Logging in a .NET 4.8 project along with anything else that targets the Microsoft dependency injection libraries, you end up with a nasty runtime DLL conflict due to this library's old usage of Microsoft.Extensions.Logging 2.1.x. See below:

flowchart TD
    Project[Project]
    AnyLibraryHere[Any Library Here]
    NLogLogging[Nlog.Extensions.Logging]
    MSLogging[Microsoft.Extensions.Logging]
    MSLoggingAbstractions[Microsoft.Extensions.Logging.Abstractions]
    MSExtDep[Microsoft.Extensions.DependencyInjection]
    MSExtDepAbs[Microsoft.Extensions.DependencyInjection.Abstractions]
    MSExtPrimitives[Microsoft.Extensions.Primitives]

    NLogLogging -->|2.1.0| MSLogging
    NLogLogging -->|2.1.0.0| MSLoggingAbstractions
    NLogLogging -->|2.1.0.0| MSExtPrimitives
    MSLogging -->|2.1.0.0| MSExtDepAbs

    Project --> NLogLogging
    Project -..-> AnyLibraryHere
    Project -->|8.0.0.0| MSLoggingAbstractions

    AnyLibraryHere -->|8.0.0.0| MSExtDepAbs
    MSExtDep -->|8.0.0.0| MSExtDepAbs

    MSLoggingAbstractions --> |8.0.0.0| MSExtDep
    MSLoggingAbstractions --> |8.0.0.0| MSExtDepAbs

    linkStyle 0,1,2,3 stroke:#f33
    style Project fill:#ffc,color:black
    style NLogLogging fill:#f99,color:#000,stroke:#333,stroke-width:4px
snakefoot commented 6 months ago

Sadly enough then .NET Framework have become the friend, that no one wants to hang out with. Microsoft have decided that .NET 4.6.1 (and newer) can be used to create ASP.NET Core2.1 Applications.

One solution is to explicit include "Microsoft Extensions Logging"-nuget-package (ver. 8.0) to the "Project" together with "Nlog.Extensions.Logging" (ver. 5.3.8).

Another solution is updating "Project" from .NET Framework to .NET8.

snakefoot commented 6 months ago

Closing issue due to inactivity.