Exemplo n.º 1
0
        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)
                                                );
            });
        }
Exemplo n.º 2
0
        private static LogLevel GetDbMinimumLevelFromConfig()
        {
            var configuration        = ApplicationConfiguration.Read <UlearnConfiguration>();
            var minimumLevelString   = configuration.HostLog.MinimumLevel ?? "debug";
            var dbMinimumLevelString = configuration.HostLog.DbMinimumLevel ?? "";

            if (!LoggerSetup.TryParseLogLevel(minimumLevelString, out var minimumLevel))
            {
                minimumLevel = LogLevel.Debug;
            }
            if (!LoggerSetup.TryParseLogLevel(dbMinimumLevelString, out var dbMinimumLevel))
            {
                dbMinimumLevel = minimumLevel;
            }
            return(dbMinimumLevel);
        }
Exemplo n.º 3
0
		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)
				);
			});
		}