serilog / serilog-extensions-logging

Serilog provider for Microsoft.Extensions.Logging

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could not load file or assembly 'Microsoft.Extensions.Logging, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

gonace opened this issue · comments

Hi
We're having problem upgrading from Serilog.Extensions.Logging version 3.1.0 to 7.0.0 for a projekt running Microsoft.Azure.Functions.

[2023-07-05T06:28:57.034Z] Found D:\laget.Auditing\laget.Auditing.Persistor\laget.Auditing.Persistor.csproj. Using for user secrets file configuration.
[2023-07-05T06:28:57.532Z] Error configuring services in an external startup class.
[2023-07-05T06:28:57.533Z] Error configuring services in an external startup class. laget.Auditing.Persistor: Could not load file or assembly 'Microsoft.Extensions.Logging, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
[2023-07-05T06:28:57.573Z] A host error has occurred during startup operation 'a5a65675-e245-48b6-bece-bdd5d72b0385'.
[2023-07-05T06:28:57.574Z] Microsoft.Azure.WebJobs.Script: Error configuring services in an external startup class. laget.Auditing.Persistor: Could not load file or assembly 'Microsoft.Extensions.Logging, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Value cannot be null. (Parameter 'provider')

The nuget package Microsoft.Azure.WebJobs reference to Microsoft.Extensions.Logging version 2.1.1 and might be the culprit?

With the .proj file looking like this

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="DogStatsD-CSharp-Client" Version="8.0.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.11.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />
    <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
    <PackageReference Include="Serilog" Version="3.0.1" />
    <PackageReference Include="Serilog.Extensions.Logging" Version="7.0.0" />
    <PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
    <PackageReference Include="Serilog.Sinks.Elasticsearch" Version="9.0.3" />
    <PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\laget.Auditing.Sinks.Elasticsearch\laget.Auditing.Sinks.Elasticsearch.csproj" />
    <ProjectReference Include="..\laget.Auditing.Sinks.MongoDB\laget.Auditing.Sinks.MongoDB.csproj" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

We're now out of ideas on how to solve this, so we're asking if anyone else have the same problem and manage to find a soultion?

The projekt is in a public repository, and can be found here: https://github.com/laget-se/laget.Auditing

Hi! I think - based on what I've seen posted elsewhere - that Azure Functions is pretty tightly bound to .NET 6 and the corresponding extensions packages. Have you tried adding a direct <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />, though?

Sticking with the earlier version of this library might be necessary, until it and Azure Functions target .NET 8 later in the year, otherwise.

HTH,
Nick

Hi! I think - based on what I've seen posted elsewhere - that Azure Functions is pretty tightly bound to .NET 6 and the corresponding extensions packages. Have you tried adding a direct <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />, though?

Sticking with the earlier version of this library might be necessary, until it and Azure Functions target .NET 8 later in the year, otherwise.

HTH, Nick

Hi
Thanks for the reply, we've tried adding a direct reference as you described which ended in the same outcome.

I find if kind of hard to find information of Azure Functions and the .NET libraries, seems like those repos have been "silent" for at least a year or two.

But thanks for the .NET 8 and Azure Functions information.

Regards
Erik