简体   繁体   English

如何滚动类似于 log4net 的 Serilog 文本文件?

[英]How roll Serilog text files similar to log4net?

I wounder how to setup Serilog.Sinks.File to produce this:我知道如何设置 Serilog.Sinks.File 来产生这个:

log.txt <-- current log
log20200704.txt  <-- rolled over yesterday log
log20200703.txt

instead of:代替:

log20200705.txt <-- current log
log20200704.txt  <-- rolled over yesterday log
log20200703.txt

I am used to such behavior since log4net days.从 log4net 时代开始,我就习惯了这种行为。

This is currently not supported by the Serilog.Sinks.File and there are no plans to support it in the short term. Serilog.Sinks.File目前不支持此功能,并且短期内没有计划支持它。 You can see a long discussion around this on the link below:你可以在下面的链接上看到一个关于这个的长篇讨论:

Fixed filename with rolling archive files #40修复了带有滚动存档文件的文件名 #40

You can see an initial attempt to add this feature as a separate package (though it's still early days and has known limitations) on this repository: https://github.com/dfacto-lab/serilog-sinks-file您可以在此存储库中看到最初尝试将此功能添加为单独的 package(尽管它还处于早期阶段并且已知限制): https://github.com/dfacto-lab/serilog-sinks-file

Of course, you can always roll your own version of Serilog.Sinks.File that adds the behavior you're looking for.当然,您始终可以滚动您自己的Serilog.Sinks.File版本,以添加您正在寻找的行为。


Other, related links:其他,相关链接:

Serilog does not support this feature yet. Serilog 尚不支持此功能。 You can find the discussion here.你可以在这里找到讨论。 There is also a workaround in place:)还有一个解决方法:)

https://github.com/serilog/serilog-sinks-file/issues/40 https://github.com/serilog/serilog-sinks-file/issues/40

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM