serilog - Serilog Selflog 仅将异常数据写入文件一次
问题描述
我正在使用 asp.net MVC 应用程序。在我的应用程序中,我需要获取 serilog 的内部异常数据。Serilog 提供从以下代码获取异常数据:
Serilog.Debugging.SelfLog.Enable(TextWriter.Synchronized(file));
HiTrustLog.HiTrustLogger.Information(log);
Serilog.Debugging.SelfLog.Disable();
Serilog 库只写入文件异常数据一次,然后第二次不写入。只是,当内部异常发生时,我需要它写入异常数据
解决方案
ILogger 在全局 asax.cs 中只创建了一次问题。所以,selflog 会写一次日志。在创建 Ilogger 之前触发日志事件时,它可以正常工作
推荐阅读
- r - 有条件地在另一个数据框中查找值以填充 R 中的列
- function - 获得稳定的 BSC 代币价格
- python - 为什么第二次编译后loss会飙升?
- c# - 在 vsix C# 项目中将字形图标添加到新边距
- javascript - 将JS返回值作为参数传递给Controller中的ActionLink
- react-native - 将本机传递数据反应到另一个屏幕
- git - Git Diff:仅突出显示字符更改,而不是行更改
- angular - 如何将 ElementRef 转换为 NgModel
- javascript - 你如何计算过去的 cron 作业时间表?
- javascript - 文件中包含的 JS 函数没有被调用?