serilog-settings-appsettings icon indicating copy to clipboard operation
serilog-settings-appsettings copied to clipboard

Constructor parameter to JsonFormatter given from xml

Open Friendry opened this issue 4 years ago • 4 comments

Hello, How can I add the 'renderedMessage = true' in the appsettings file for the JsonFormatter? In the code it's easy, but I haven't managed to do this in the appsettings. Normally the 'renderedMessage' is given to the constructor of the JsonFormatter. Is there a way to do this in the in the xml?

The config part of the file looks like this:

<add key="serilog:using:File" value="Serilog.Sinks.File" />
<add key="serilog:write-to:File.path" value="Logs/Log_.txt" />
<add key="serilog:write-to:File.shared" value="true" />
<add key="serilog:write-to:File.rollingInterval" value="Day" />
<add key="serilog:write-to:File.formatter" value="Serilog.Formatting.Json.JsonFormatter" />

Friendry avatar Aug 17 '21 15:08 Friendry

I just hit this now 3 years later. Anyone have an answer?

We tried:

<add key="serilog:write-to:File.formatter.renderedMessage" value="true" />
<add key="serilog:write-to:File.formatter:renderedMessage" value="true" />
<add key="serilog:write-to:File.formatter::renderedMessage" value="true" />
<add key="serilog:write-to:File.formatter_renderedMessage" value="true" />

VictorioBerra avatar Oct 11 '24 17:10 VictorioBerra

Hi @VictorioBerra! I don't think any work's been done on this. Configuration is in a bit of an awkward spot right now, with most energy going into the Microsoft.Extensions.Configuration integration, but with some big opportunities to unify and improve all of the configuration methods still on the table. Unfortunately it's a bit of a tedious area to work in.

nblumhardt avatar Oct 11 '24 20:10 nblumhardt

Thanks for the reply @nblumhardt

We decided to just configure this specific sink in code instead of configuration. Not ideal but it works.

VictorioBerra avatar Oct 11 '24 20:10 VictorioBerra

This is old (and probably outdated) but at some point I tried to document the capabilities of the appsettings support ... maybe there is an example in there :

  • https://github.com/tsimbalar/serilog-settings-comparison/blob/master/docs/README.md

tsimbalar avatar Oct 11 '24 20:10 tsimbalar