예제 #1
0
 private static LoggerConfiguration ApplyActualLoggerConfiguration(
     this LoggerConfiguration logger,
     IConfiguration configuration,
     IHostEnvironment environment)
 => logger
 .ApplyStartingConfiguration()
 .Enrich.WithProperty("Application", environment.ApplicationName)
 .Enrich.WithProperty("Environment", environment.EnvironmentName)
 .WriteTo.Logger(log => log
                 .MinimumLevel.ControlledBy(LevelSwitch)
                 .Filter.ByExcluding(configuration["Serilog:Seq:Ignored"] ?? "false")
                 .WriteTo.File(
                     Path.Combine(Directory.GetCurrentDirectory(), "Logs", $"{environment.ApplicationName}-.log"),
                     fileSizeLimitBytes: 31457280,
                     retainedFileCountLimit: 10,
                     rollingInterval: RollingInterval.Day,
                     rollOnFileSizeLimit: true,
                     shared: true)
                 .WriteTo.Seq(
                     configuration["Seq:Uri"] ?? "about:local",
                     apiKey: configuration["Seq:ApiKey"] ?? string.Empty));