我在我的 Asp.net 核心程序中使用 serilog 和 Seq,但我不断收到上述错误。我的 Seq 服务器正在运行。appsetting.json
分别在和中找到下面的配置startup.cs
。
应用设置.json
"Serilog": {
"Destructure": [
{
"Name": "With",
"Args": { "policy": "Sample.CustomPolicy, Sample" }
},
{
"Name": "ToMaximumDepth",
"Args": { "maximumDestructuringDepth": 4 }
},
{
"Name": "ToMaximumStringLength",
"Args": { "maximumStringLength": 100 }
},
{
"Name": "ToMaximumCollectionCount",
"Args": { "maximumCollectionCount": 10 }
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"MinimumLevel": "Debug",
"Properties": {
"Application": "Sample"
},
"Using": [ "Serilog.Sinks.File", "Serilog.Sinks.Async", "Serilog.Sinks.Console", "Serilog.Sinks.Seq", "Serilog.Sinks.Graylog" ],
"WriteTo": [
{
"Name": "Console"
},
{
"Name": "File",
"Args": { "path": "Loggers/logs.txt" }
},
{
"Args": {
"serverUrl": "http://localhost:5341"
},
"Name": "Seq"
}
]
}
启动.cs
services.AddLogging(loggingBuilder =>
{
loggingBuilder.AddSeq("Seq");
});