尝试将以下代码配置转换为配置行:
.WriteTo.RollingFile(@"C:\Foo\Bar-{Date}.txt", retainedFileCountLimit: null)
滚动文件接收器的文档指出,为了无限期地保留日志,必须将retainedFileCountLimit
参数发送为null
.
我试过这个
<add key="serilog:write-to:RollingFile.pathFormat" value="C:\Foo\Bar-{Date}.txt" />
<add key="serilog:write-to:RollingFile.retainedFileCountLimit" value="null" />
但正如我所料,null
文字不被接受,而且似乎试图直接转换为 Int32。
这是堆栈跟踪以供参考:
[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