/// <summary>Loads the NLog.config file from the <see cref="DataFolder"/>, if it exists.</summary> public static ILoggerFactory Create(LogSettings settings) { return(ExtendedLoggerFactory.Create(builder => { LoggingConfiguration.ConfigureConsoleFilters(builder, settings); builder.AddFilter("Default", LogLevel.Information) .AddFilter("System", LogLevel.Warning) .AddFilter("Microsoft", LogLevel.Warning) .AddFilter("Microsoft.AspNetCore", LogLevel.Error) .AddFilter <ConsoleLoggerProvider>("Stratis.Bitcoin.*", LogLevel.Information) .AddConsole(); builder.SetMinimumLevel(LogLevel.Debug); } )); }
/// <summary> /// Configure the console logger and set it to filter logs not related to the fullnode. /// </summary> /// <param name="loggerFactory">The logger factory to add the console logger.</param> /// <returns>The new console settings.</returns> public static void AddConsoleWithFilters(this ILoggerFactory loggerFactory) { ConsoleLoggerSettings consoleLoggerSettings = new ConsoleLoggerSettings { Switches = { { "Default", Microsoft.Extensions.Logging.LogLevel.Information }, { "System", Microsoft.Extensions.Logging.LogLevel.Warning }, { "Microsoft", Microsoft.Extensions.Logging.LogLevel.Warning }, { "Microsoft.AspNetCore", Microsoft.Extensions.Logging.LogLevel.Error } } }; ConsoleLoggerProvider consoleLoggerProvider = new ConsoleLoggerProvider(consoleLoggerSettings); loggerFactory.AddProvider(consoleLoggerProvider); ExtendedLoggerFactory extendedLoggerFactory = loggerFactory as ExtendedLoggerFactory; Guard.NotNull(extendedLoggerFactory, nameof(extendedLoggerFactory)); extendedLoggerFactory.ConsoleLoggerProvider = consoleLoggerProvider; extendedLoggerFactory.ConsoleSettings = consoleLoggerSettings; }