Lassi Autio
Lassi Autio

Reputation: 1249

write-to not working from AppSettings with Serilog 2.1

I used Serilog 1.x and following worked there:

In code:

Log.Logger = new LoggerConfiguration().ReadFrom.AppSettings().CreateLogger();

In app.config:

<add key="serilog:write-to:RollingFile.pathFormat" value="C:\Temp\MyService\Log-{Date}.log" />

But now with Serilog 2.1 seems that any write-to isn't working from app.config. When I put them straight to code it works but I want them to app.config. What is wrong with my code/app.config?

Upvotes: 1

Views: 1128

Answers (1)

Lassi Autio
Lassi Autio

Reputation: 1249

I luckily resolved this myself. Seems that in 2.x version there need to be serilog:using for every sink in app.config. I added following to use RollingFile and Seq:

<add key="serilog:using:RollingFile" value="Serilog.Sinks.RollingFile" />
<add key="serilog:using:Seq" value="Serilog.Sinks.Seq" />

And now both rolling files and Seq works.

Upvotes: 1

Related Questions