Shetty
Shetty

Reputation: 1892

Controlling settings for serilog in app.config

I need to log events in Json format using Serilog. I want to use RollingFileSink. According to the following link, we cannot specify TextFormatter in App.config file. How to specify JsonFormatter in Web.config for SeriLog?

Is is possible to specify all other configurations like file path in app.config and then add textformatter as JsonFormatter in code while initialing the logger?

Upvotes: 2

Views: 941

Answers (1)

Nicholas Blumhardt
Nicholas Blumhardt

Reputation: 31797

Just using plain settings works well for this, e.g.:

<add key="filePath" value="C:..." />

And:

WriteTo.RollingFile(..., ConfigurationManager.AppSettings["filePath"])

Upvotes: 1

Related Questions