Closed xneg closed 4 years ago
Hi!
There are a couple of similar issues over in the Serilog.Settings.Configuration repo.
In a nutshell, it's not possible to pass parameters to constructors at present.
I haven't tried this, but I guess a kind of workaround would be to create your own class that extended the formatter in question and provided the values you want (with a parameterless ctor!)
Ok, thank you. I was thinking about possibility you proposed. But I thought there is some ready solution. Sorry for opening duplicate issue.
Not a problem, I'm happy to help 😄
I think this is possible now. refer https://github.com/serilog/serilog-settings-configuration/issues/225#issuecomment-1760091673
{
"Name": "File",
"Args": {
"path": "log.json",
"rollingInterval": "Day",
"retainedFileCountLimit": 7,
"formatter": {
"type": "Serilog.Formatting.Json.JsonFormatter, Serilog",
"renderMessage": true
}
}
}
In code I can setup formatter like this
Can I do the same thing in appsettings.json? This one does not work: