我需要使用 Serilog.Exceptions 包来捕获异常。从 appsettings.json 读取 Serilog
{
"Serilog": {
"Using": [
"Serilog.Sinks.RollingFile",
"Serilog.Sinks.Seq"
],
"WriteTo": [
{
"Name": "RollingFile",
"Args": {
"restrictedToMinimumLevel": "Debug",
"pathFormat": "myPath\\log-{Date}.log"
}
},
{
"Name": "RollingFile",
"Args": {
"restrictedToMinimumLevel": "Error",
"pathFormat": "myPath\\error-{Date}.log"
}
},
{
"Name": "Seq",
"Args": {
"serverUrl": "myUrl",
"apiKey": "myApiKey"
}
}
],
"Enrich": [
"FromLogContext",
"WithMachineName",
"WithThreadId"
],
"Properties": {
"Application": "myApplicationName"
}
}
}
在我的startup.cs
var logger = new LoggerConfiguration()
.Enrich.WithExceptionDetails()
.ReadFrom.Configuration(Configuration)
.CreateLogger();
Log.Logger = logger;
但它不起作用。我是否需要在 appsettings.json 中为 Serilog.Exceptions 包添加一些其他属性?还是 appsettings.json 配置正确?我究竟做错了什么?谢谢