configures serilog retained file count
All checks were successful
PiwigoDirectorySync/pipeline/head This commit looks good

This commit is contained in:
Philipp Häfelfinger 2023-09-11 23:08:40 +02:00
parent 5123b59f70
commit baa0117e1e

View File

@ -14,14 +14,13 @@ using Spectre.Console.Cli;
const string outputTemplateConsole = "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}: {Message}{NewLine}"; const string outputTemplateConsole = "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}: {Message}{NewLine}";
const string outputTemplateFile = "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message}{NewLine}{NewLine}{Exception}{NewLine}"; const string outputTemplateFile = "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message}{NewLine}{NewLine}{Exception}{NewLine}";
Log.Logger = new LoggerConfiguration() Log.Logger = new LoggerConfiguration().MinimumLevel.Debug()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning) .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.MinimumLevel.Override("System", LogEventLevel.Warning) .MinimumLevel.Override("System", LogEventLevel.Warning)
.MinimumLevel.Override("Piwigo.Client", LogEventLevel.Warning) .MinimumLevel.Override("Piwigo.Client", LogEventLevel.Warning)
.Enrich.FromLogContext() .Enrich.FromLogContext()
.WriteTo.Console(LogEventLevel.Information, outputTemplateConsole, theme: AnsiConsoleTheme.Code) .WriteTo.Console(LogEventLevel.Information, outputTemplateConsole, theme: AnsiConsoleTheme.Code)
.WriteTo.File("logs/PiwigoDirectorySync.txt", LogEventLevel.Debug, outputTemplate:outputTemplateFile, rollingInterval: RollingInterval.Day) .WriteTo.File("logs/PiwigoDirectorySync.txt", LogEventLevel.Debug, outputTemplateFile, rollingInterval: RollingInterval.Day, retainedFileCountLimit: 90)
.CreateLogger(); .CreateLogger();
var registrations = new ServiceCollection(); var registrations = new ServiceCollection();