private static void SetupLog(IVostokCompositeLogBuilder logBuilder, UlearnConfiguration ulearnConfiguration) { var log = LoggerSetup.Setup(ulearnConfiguration.HostLog, ulearnConfiguration.GraphiteServiceName, false); logBuilder.AddLog(log); logBuilder.CustomizeLog(logCustomization => logCustomization.WithMinimumLevel(LogLevel.Debug)); const LogLevel minimumLevel = LogLevel.Info; var dbMinimumLevelString = ulearnConfiguration.HostLog.DbMinimumLevel ?? ""; if (!LoggerSetup.TryParseLogLevel(dbMinimumLevelString, out var dbMinimumLevel)) { dbMinimumLevel = minimumLevel; } var min = dbMinimumLevel > minimumLevel ? minimumLevel : dbMinimumLevel; logBuilder.SetupHerculesLog(herculesLogBuilder => { herculesLogBuilder.SetStream(ulearnConfiguration.Hercules.Stream); herculesLogBuilder.SetApiKeyProvider(() => ulearnConfiguration.Hercules.ApiKey); herculesLogBuilder.CustomizeLog(lb => lb .WithMinimumLevelForSourceContext("ULearnDb", dbMinimumLevel) // Database .WithMinimumLevel(min) ); }); }
private static void SetupLog(IVostokCompositeLogBuilder logBuilder, UlearnConfiguration ulearnConfiguration) { var log = LoggerSetup.Setup(ulearnConfiguration.HostLog, ulearnConfiguration.GraphiteServiceName, false); logBuilder.AddLog(log); logBuilder.CustomizeLog(logCustomization => logCustomization.WithMinimumLevel(LogLevel.Debug)); const LogLevel minimumLevel = LogLevel.Info; var dbMinimumLevelString = ulearnConfiguration.HostLog.DbMinimumLevel ?? ""; if (!LoggerSetup.TryParseLogLevel(dbMinimumLevelString, out var dbMinimumLevel)) dbMinimumLevel = minimumLevel; var min = dbMinimumLevel > minimumLevel ? minimumLevel : dbMinimumLevel; logBuilder.SetupHerculesLog(herculesLogBuilder => { herculesLogBuilder.SetStream(ulearnConfiguration.Hercules.Stream); herculesLogBuilder.SetApiKeyProvider(() => ulearnConfiguration.Hercules.ApiKey); herculesLogBuilder.CustomizeLog(lb => lb .DropEvents(LoggerSetup.FilterLogs) .SelectEvents(le => le.Level >= (LoggerSetup.IsDbSource(le) ? dbMinimumLevel : minimumLevel)) .WithMinimumLevel(min) ); }); }