serilog-enrichers-clientinfo icon indicating copy to clipboard operation
serilog-enrichers-clientinfo copied to clipboard

Old Serilog.dll will be used when targeting .NET Framework

Open LucaMahler opened this issue 1 year ago • 3 comments

I've written a company-internal logging library within which I utilize both Serilog as well as some enrichers. The library itself targets .NET Standard 2.0. So far so good.

The problem arises when I install this library (NuGet) within our older .NET Framework (4.8.1) projects.

Unfortunately, the .csproj will look like this:

<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
  <HintPath>packages\Serilog.Enrichers.ClientInfo.2.0.3\lib\net462\Serilog.dll</HintPath>
</Reference>

This Serilog.dll is an old one which is not campatible with the one installed (3.1.1), so I get a runtime error: Method not found: 'Serilog.LoggerConfiguration Serilog.Configuration.LoggerSinkConfiguration.Conditional(System.Func2<Serilog.Events.LogEvent,Boolean>, System.Action1<Serilog.Configuration.LoggerSinkConfiguration>)'.

We don't face this issue with other enricher libraries.

LucaMahler avatar May 21 '24 15:05 LucaMahler

Unfortunately, the .csproj will look like this: <Reference Include="Serilog, Version=2.0.0.0,

Serilog.Enrichers.ClientInfo.2.0.3 has a dependency on Serilog v2.4.0, why is it v2.0.0.?

What other enrichers do you have?

mo-esmp avatar May 22 '24 22:05 mo-esmp

What other enrichers do you have?

Besides yours, these 3:

  • Serilog.Enrichers.AssemblyName
  • Serilog.Enrichers.Environment
  • Serilog.Enrichers.GlobalLogContext

It's confusing that your package will generate 5 directories within the lib directory (for all target frameworks), but /net462 contains a Serilog.dll which unfortunately is being used. Why is it even in here?

LucaMahler avatar May 23 '24 06:05 LucaMahler

It's confusing that your package will generate 5 directories within the lib directory

Because the package supports 5 different target frameworks net462;netstandard2.0;netstandard2.1;net6.0;net7.0.

Serilog.Enrichers.AssemblyName has a dependency on Serilog v2.0.0 and it will be used and Serilog.Enrichers.ClientInfo has a dependency on Serilog.LoggerConfiguration method to read configuration from appsettings.json which is not available in Serilog v2.0.0. Try to install Serilog.Settings.Configuration v2.4.0 and it might fix the issue.

mo-esmp avatar May 23 '24 07:05 mo-esmp