I am adding Serilog to the project and I specifically want to add Serilog.Exceptions
as well. Following the guideline I've added just the Exceptions enricher successfully, but I also need the destructures mentioned in the linked page.
The following works fine using fluent configuration:
config.Enrich.WithExceptionDetails(new DestructuringOptionsBuilder()
.WithDefaultDestructurers()
.WithDestructurers(new ExceptionDestructurer[]
{
new DbUpdateExceptionDestructurer(),
new SqlExceptionDestructurer()
}));
However, I'm struggling to get it configured using JSON config like this:
config.ReadFrom.Configuration(context.Configuration);
Here's what I've tried already without much luck:
"Enrich": [
{ "Name": "FromLogContext" },
{
"Name": "WithExceptionDetails",
"Args": {
"With": "DbUpdateException, SqlException"
}
}
]
and also:
"Enrich": [ "FromLogContext", "WithExceptionDetails" ],
"Destructure": [
{
"Name": "With",
"Args": { "policy": "DbUpdateException, SqlException" }
}
]
How do I configure the fluent version using JSON?
Destructure
from Configuration, try to refer Add support for serilog-settings-configuration #58 – Pericycle