我正在将 Serilog 添加到项目中,我也特别想添加Serilog.Exceptions
。按照指南,我成功地添加了异常丰富器,但我还需要链接页面中提到的解构。
使用流畅的配置可以正常工作:
config.Enrich.WithExceptionDetails(new DestructuringOptionsBuilder()
.WithDefaultDestructurers()
.WithDestructurers(new ExceptionDestructurer[]
{
new DbUpdateExceptionDestructurer(),
new SqlExceptionDestructurer()
}));
但是,我正在努力使用这样的 JSON 配置对其进行配置:
config.ReadFrom.Configuration(context.Configuration);
这是我已经尝试过的方法,但运气不佳:
"Enrich": [
{ "Name": "FromLogContext" },
{
"Name": "WithExceptionDetails",
"Args": {
"With": "DbUpdateException, SqlException"
}
}
]
并且:
"Enrich": [ "FromLogContext", "WithExceptionDetails" ],
"Destructure": [
{
"Name": "With",
"Args": { "policy": "DbUpdateException, SqlException" }
}
]
如何使用 JSON 配置流畅的版本?