I created a customized JSON Formatter which extends ITextFormatter And try to add it to appsetting.json like this:
"WriteTo": [
{
"Name": "Console",
"Args": {
"formatter": "CustomizedJSONFormatter"
// "formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog"
}
}
]
The default jsonFormatter works fine as shown in the commented line. But I will get an error if I want to add the customized one: InvalidCastException: Invalid cast from 'System.String' to 'Serilog.Formatting.ITextFormatter'.
Is there anyway to solve this?
Thanks!
As suggested by @SLaks, the assembly-qualified type name is required:
MyNamespace.CustomizedJsonFormatter, MyAssembly
It needs to be used like below:
"WriteTo": [
{
"Name": "Console",
"Args": {
"customFormatter": "Serilog.Formatting.Elasticsearch.ElasticsearchJsonFormatter,Serilog.Formatting.Elasticsearch"
}
}
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With