Beispiel #1
0
        public ICollection <ILoggerConfiguration> GetLoggerConfigurations()
        {
            var sources = SerilogConfiguration.GetSources();
            var list    = new List <ILoggerConfiguration>();

            foreach (var(k, v) in sources)
            {
                list.Add(new Steeltoe.Extensions.Logging.LoggerConfiguration(k, FromSerilog(v.Default), FromSerilog(v.LevelSwitch.MinimumLevel)));
            }
            return(list);
        }
Beispiel #2
0
 public void SetLogLevel(string category, LogLevel?level)
 {
     try
     {
         var serilogLevel = level.HasValue ? ToSerilog(level.Value) : SerilogConfiguration.GetDefaultLevel(category);
         SerilogConfiguration.SetLogLevel(category, serilogLevel);
         _logger.LogInformation($"SetLogLevel({category}, {serilogLevel}");
     }
     catch (Exception ex)
     {
         var dotnetLevel = level.HasValue ? level.Value.ToString() : "";
         _logger.LogError(ex, $"Failed SetLogLevel({category}, {dotnetLevel})");
         throw;
     }
 }
Beispiel #3
0
 public static void Main(string[] args)
 {
     SerilogConfiguration.Configure();
     CreateWebHostBuilder(args).Build().Run();
 }