gpt4 book ai didi

azure - 当我发布到 Azure 时,Serilog WriteTo.RollingFile 似乎会创建 500 错误代码

转载 作者:行者123 更新时间:2023-12-03 03:08:54 25 4
gpt4 key购买 nike

我向 Azure 发布了一个基本的 ASP.NET Core 应用程序,尝试使用 Serilog,但发布后出现 500 错误。当我注释掉 RollingFile Sink 时,它发布得很好,没有错误。有什么原因可能会发生这种情况吗?它在我的本地计算机上也运行良好。

      public Startup(IHostingEnvironment appEnv)
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information()
//.WriteTo.RollingFile(Path.Combine(appEnv.WebRootPath, "log-{Date}.txt"), retainedFileCountLimit: 5)
.CreateLogger();
}

最佳答案

env.WebRootPath 可能为 null。在这种情况下,Path.Combine() 将(据我所知)抛出 ArgumentNullException,这将导致 500 个错误。

关于azure - 当我发布到 Azure 时,Serilog WriteTo.RollingFile 似乎会创建 500 错误代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41495748/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com