Trying to convert the following code configuration into a config line:
.WriteTo.RollingFile(@"C:\Foo\Bar-{Date}.txt", retainedFileCountLimit: null)
The documentation for the rolling file sink states that in order to retain the logs indefinitely one must send the retainedFileCountLimit
parameter as null
.
I tried this
<add key="serilog:write-to:RollingFile.pathFormat" value="C:\Foo\Bar-{Date}.txt" />
<add key="serilog:write-to:RollingFile.retainedFileCountLimit" value="null" />
but as I expected the null
literal is not accepted, moreover it seems like a direct conversion to Int32 is attempted.
Here is the stack trace for reference:
[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +14345541
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +305
System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) +859
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +248
System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +536
System.Linq.Enumerable.ToList(IEnumerable`1 source) +80
Serilog.Extras.AppSettings.PrefixedAppSettingsReader.ConfigureLogger(LoggerConfiguration loggerConfiguration) +1983
Serilog.LoggerConfigurationAppSettingsExtensions.ReadAppSettings(LoggerConfiguration loggerConfiguration) +16