1

我将如何将 outputTemplate 添加到此代码中?

Serilog.Log.Logger = new LoggerConfiguration()
                .MinimumLevel.Information()
                .Enrich.WithMachineName()
                .WriteTo.Sink(new RollingFileSink(applicationLogsPath, new JsonFormatter(), 1000000000, 10))
                .CreateLogger();
4

1 回答 1

0

如果您的目标是将人类可读的文本写入文件而不是 JSON,您可以使用WriteTo.RollingFile()

Serilog.Log.Logger = new LoggerConfiguration()
            .MinimumLevel.Information()
            .Enrich.WithMachineName()
            .WriteTo.RollingFile(
                 applicationLogsPath,
                 outputTemplate: "<output template goes here>",
                 fileSizeLimitBytes: 1000000000,
                 retainedFileCountLimit: 10)
            .CreateLogger();
于 2015-08-23T22:17:39.557 回答