示例#1
0
 public static LoggerConfiguration CreateDefaultConfiguration(SerilogRollingFileConfiguration fileConfiguration)
 {
     return new LoggerConfiguration()
         .Enrich.WithThreadId()
         .MinimumLevel.ControlledBy(fileConfiguration.GetLoggingLevelSwitch())
         .WriteTo.ColoredConsole(
             outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} - {ThreadId} - [{Level}] {Message}{NewLine}{Exception}")
         .WriteTo.RollingFile(
             fileConfiguration.FilePath,
             fileSizeLimitBytes: fileConfiguration.FileSize,
             retainedFileCountLimit: fileConfiguration.NumberOfFilesToKeep);
 }
示例#2
0
 public SerilogLogger(SerilogRollingFileConfiguration fileConfiguration)
 {
     _logger =
         CreateDefaultConfiguration(fileConfiguration)
         .CreateLogger();
 }