启用 SelfLog 获取真实错误
在 Program.cs 开头加上:
Serilog.Debugging.SelfLog.Enable(msg => Console.WriteLine($"[SERILOG SELFLOG] {msg}"));
例如下面:
public static void Main(string[] args)
{
Serilog.Debugging.SelfLog.Enable(msg => Console.WriteLine($"[SERILOG SELFLOG] {msg}"));
CreateHostBuilder(args).Build().Run();
}
运行程序,观察控制台输出。大概率你会看到类似:
-
"reason": "illegal_argument_exception" -
"reason": "mapper_parsing_exception" -
"IndexPatternNotFoundException" -
或者
"DocumentAlreadyExistsException"等。
如果 SelfLog 没有输出,说明日志根本没发送到 Sink,检查 WriteTo.Elasticsearch 是否真的被调用。
浙公网安备 33010602011771号