I am using SeriLog for logging in my IdentityServer3-based authentication service. I just replaced the serilog.sinks.literate plug in with the serilog.sinks.file plug in in order to get the rolling file capability offered by the File plug in. When I use the File plug in with the following configuration code in Startup.cs, it works as I expect. (I'm only using the RolloverInterval.Minute for testing. I'll switch to RolloverInterval.Day when I deploy the code.)
Log.Logger = new LoggerConfiguration()
.WriteTo.File("E:\\Site\\AuthSvc\\Trace.log", rollingInterval: RollingInterval.Minute, retainedFileCountLimit: 10)
.CreateLogger();
As I said, that works as expected, creating a new file each minute.
Now I'm trying to use the serilog.settings.appsettings plug in to manage all of that configuration in appSettings instead of in code. So I changed the above code to:
Log.Logger = new LoggerConfiguration()
.ReadFrom.AppSettings()
.CreateLogger();
And I included the following in my web.config appSettings:
<add key="serilog:minimum-level" value="Debug"/>
<add key="serilog:using:File" value="Serilog.Sinks.File"/>
<add key="serilog:write-to:File.path" value="E:\Site\AuthSvc\Trace.log"/>
<add key="serilog:write-to:File.rollingInterval" value="RollingInterval.Minute"/>
<add key="serilog:write-to:File.retainedFileCountLimit" value="10"/>
When I run the service with the above configuration, I get the error message "Requested value 'RollingInterval.Minute' was not found." Similar error occurs with any RollingInterval value.
If I remove the last two appSettings, it works fine. Am I doing something wrong or does the appSettings plug in not support the rolling file features of the File sink plug in?