我正在尝试在我的Azure函数应用程序项目(.net 6)My Startup.cs中包含serilog
public override void Configure(IFunctionsHostBuilder builder)
{
Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.WriteTo.AzureAnalytics(workspaceId: "xxxxxxxxxxxxxxxxxxxxxxx",
authenticationId: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
.CreateLogger();
builder.Services.AddLogging(lb => lb.AddSerilog(Log.Logger,true));
ConfigureServices(builder.Services);
}
private void ConfigureServices(IServiceCollection services)
{
services.RegisterApplicationServices();
}
字符串
我的csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<DockerFastModeProjectMountDirectory>/home/site/wwwroot</DockerFastModeProjectMountDirectory>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="4.0.0" />
<PackageReference Include="Serilog.Sinks.AzureAnalytics" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\xxxx.Application\xxxxx.Application.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
型
x1c 0d1x的数据
一切似乎都在地方,但我得到这个错误时,在本地运行的应用程序
启动操作“677 c62 b7-bf 08 -4306- 812 c-e7 ea 5 fbd 5678”期间发生主机错误。[2023-08- 01 T15:21:25.432Z] Microsoft.Azure.WebJobs.脚本:在外部启动类中配置服务时出错。ConcurICS.FunctionApp:未能加载文件或程序集“Microsoft.Extensions.Logging,Version=7.0.0.0,Culture=neutral,PublicKeyToken= adb 9793829 ddae 60”。系统找不到指定的文件。
2条答案
按热度按时间uurv41yg1#
尝试将
Serilog.Extensions.Logging
降级到3.1.0
版本(在我的示例设置中,我使用的是Serilog.Extensions.Hosting
的5.0.1版本,这取决于它)vsmadaxz2#
这可能听起来很愚蠢,但请在包管理器控制台中尝试以下操作:
字符串
它为我解决了太多不应该成为问题的软件包问题。
如果这还不管用的话。你能提供你已经尝试过的东西吗?