我一直在研究如何使用 Serilog 写入 Azure 日志流。我也在这里找到了一些答案;例如,一个答案是建议登录到特定文件夹中的文件(home\LogFiles\http\...
),但它似乎对我不起作用。
我尝试使用Trace https://github.com/serilog/serilog-sinks-trace and Debug https://github.com/serilog/serilog-sinks-debug接收器,但我无法在 Azure 日志流中看到我的消息。
让事情变得更加令我困惑,甚至使用System.Diagnostics.Debug
or System.Diagnostics.Trace
也不行。
所以,也许有两个问题:
- 一般来说,我应该如何写入Azure日志流?
- 是否可以使用 Serilog 基础设施,同时写入日志流?
不用说,我已经在我的 Azure 应用服务中启用了“诊断日志”。
非常感谢任何帮助,
谢谢
The 文件接收器 https://github.com/serilog/serilog-sinks-file据报道,使用以下配置可以正常工作:
.WriteTo.File(
@"D:\home\LogFiles\Application\myapp.txt",
fileSizeLimitBytes: 1_000_000,
rollOnFileSizeLimit: true,
shared: true,
flushToDiskInterval: TimeSpan.FromSeconds(1))
有一些微妙之处需要注意——shared:
and flushToDiskInterval:
尤其。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)