I am using serilog and Seq in my Asp.net core program but I keep getting the above error. My Seq server is running though. Find below the configuration in the appsetting.json
and startup.cs
respectively.
Appsetting.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"
}
]
}
StartUp.cs
services.AddLogging(loggingBuilder =>
{
loggingBuilder.AddSeq("Seq");
});
For
loggingBuilder.AddSeq("Seq");
, you need to pass url instead ofSeq
.If you want to passing the configuration from
appsettings.json
, define theappsettings.json
likeAnd using like
loggingBuilder.AddSeq(Configuration.GetSection("Seq"));
.If you need to combine
serilog
andSeq
, refer Using Serilog.