Serilog有哪些文件名占位符?

时间:2017-06-07 01:00:58

标签: .net logging filenames serilog

我在使用RollingFile的.NET Core应用程序上使用Serilog。我想知道,如果有不同的文件名占位符?我只知道{Date}。

例如,我有像

这样的代码
        Log.Logger = new LoggerConfiguration()
            .MinimumLevel.Information()
            .WriteTo.RollingFile("Logs/{Date}.log")
            .CreateLogger();

{Date}等文件名还有其他选项吗?我希望按小时提供日志文件。

1 个答案:

答案 0 :(得分:5)

在撰写本文时,Serilog的Rolling File接收器支持3(3)个说明符:

  • {Date},格式为yyyyMMdd
  • {Hour},格式为yyyyMMddHH
  • {HalfHour},格式为yyyyMMddHHmm

您可以在README of the Rolling File sink以及source code of the Rolling File sink中看到它。

相关问题