Skip to content

Microsoft.NET.Sdk.Web global using statements break Serilog/NLog/log4net consumers on upgrade #20747

Closed as not planned
@nblumhardt

Description

@nblumhardt

From dotnet/templating#3359 (comment)

The .NET 6 version of Microsoft.NET.Sdk.Web introduces a default global using statement for Microsoft.Extensions.Logging. This brings MEL's ILogger into scope everywhere, breaking existing code that uses Serilog's (or another framework's) ILogger interface, with errors like:

/home/pi/dl/nix/seq/tmp/ubuntu.20.04-arm64/src/Seq/Server/Tasks/TaskRunner.cs(15,18): error CS0104: 'ILogger' is an ambiguous reference between 'Microsoft.Extensions.Logging.ILogger' and 'Serilog.ILogger' [/home/pi/dl/nix/seq/tmp/ubuntu.20.04-arm64/src/Seq/Seq.csproj]

The breakage can be worked around by adding <EnableDefaultGlobalUsing>false</EnableDefaultGlobalUsing> or similar to the project's CSPROJ file, but this is a pretty nasty papercut that penalizes users for choosing a logging library other than Microsoft's. The chore will be particularly onerous because of the number of projects affected (and volume of errors within these projects).

I'd also expect that many users will turn to the Serilog project asking for guidance or reporting the breakage as a bug, since the default assumption people make when encountering an issue like this is that "Serilog is broken on .NET 6" - which increases our support burden :-)

CC @DamianEdwards

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions