将 Serilog 与 Azure 日志流结合使用

Use Serilog with Azure Log Stream

我一直在研究如何使用 Serilog 写入 Azure 日志流。我也在这里找到了一些答案;例如,一个答案建议登录到特定文件夹中的文件 (home\LogFiles\http\...),但它似乎对我不起作用。

我尝试使用 Trace and Debug 接收器,但在 Azure 日志流中看不到我的消息。

更让我困惑的是,即使使用 System.Diagnostics.DebugSystem.Diagnostics.Trace 也不起作用。

所以,也许有两个问题:

不用说,我已经在我的 Azure 应用服务中启用了 "Diagnostic Logs"。

非常感谢任何帮助,

谢谢

据报道 file sink 可以在以下配置下正常工作:

    .WriteTo.File(
         @"D:\home\LogFiles\Application\myapp.txt",
        fileSizeLimitBytes: 1_000_000,
        rollOnFileSizeLimit: true,
        shared: true,
        flushToDiskInterval: TimeSpan.FromSeconds(1))

有一些细微之处需要注意 - shared:flushToDiskInterval: 特别是。