diff --git a/src/chocolatey.console/Program.cs b/src/chocolatey.console/Program.cs
index 85942e8ad9..4959d58144 100644
--- a/src/chocolatey.console/Program.cs
+++ b/src/chocolatey.console/Program.cs
@@ -17,6 +17,7 @@ namespace chocolatey.console
{
using System;
using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using infrastructure.adapters;
@@ -131,8 +132,8 @@ that chocolatey.licensed.dll exists at
Environment.Exit(-1);
}
- Log4NetAppenderConfiguration.set_verbose_logger_when_verbose(config.Verbose, "{0}LoggingColoredConsoleAppender".format_with(ChocolateyLoggers.Verbose.to_string()));
- Log4NetAppenderConfiguration.set_logging_level_debug_when_debug(config.Debug);
+ Log4NetAppenderConfiguration.set_logging_level_debug_when_debug(config.Debug, excludeLoggerName: "{0}LoggingColoredConsoleAppender".format_with(ChocolateyLoggers.Verbose.to_string()));
+ Log4NetAppenderConfiguration.set_verbose_logger_when_verbose(config.Verbose, config.Debug, "{0}LoggingColoredConsoleAppender".format_with(ChocolateyLoggers.Verbose.to_string()));
"chocolatey".Log().Debug(() => "{0} is running on {1} v {2}".format_with(ApplicationParameters.Name, config.Information.PlatformType, config.Information.PlatformVersion.to_string()));
//"chocolatey".Log().Debug(() => "Command Line: {0}".format_with(Environment.CommandLine));
diff --git a/src/chocolatey/infrastructure.app/runners/ConsoleApplication.cs b/src/chocolatey/infrastructure.app/runners/ConsoleApplication.cs
index 2084fe639c..39e9185c97 100644
--- a/src/chocolatey/infrastructure.app/runners/ConsoleApplication.cs
+++ b/src/chocolatey/infrastructure.app/runners/ConsoleApplication.cs
@@ -56,7 +56,7 @@ public void run(string[] args, ChocolateyConfiguration config, Container contain
// if debug is bundled with local options, it may not get picked up when global
// options are parsed. Attempt to set it again once local options are set.
// This does mean some output from debug will be missed (but not much)
- if (config.Debug) Log4NetAppenderConfiguration.set_logging_level_debug_when_debug(config.Debug);
+ if (config.Debug) Log4NetAppenderConfiguration.set_logging_level_debug_when_debug(config.Debug, excludeLoggerName: "{0}LoggingColoredConsoleAppender".format_with(ChocolateyLoggers.Verbose.to_string()));
command.handle_additional_argument_parsing(unparsedArgs, config);
diff --git a/src/chocolatey/infrastructure/logging/Log4NetAppenderConfiguration.cs b/src/chocolatey/infrastructure/logging/Log4NetAppenderConfiguration.cs
index ee2ab5dcb6..0f5e85a636 100644
--- a/src/chocolatey/infrastructure/logging/Log4NetAppenderConfiguration.cs
+++ b/src/chocolatey/infrastructure/logging/Log4NetAppenderConfiguration.cs
@@ -16,6 +16,7 @@
namespace chocolatey.infrastructure.logging
{
using System.IO;
+ using System.Linq;
using adapters;
using app;
using log4net;
@@ -108,7 +109,8 @@ private static void set_file_appender(string outputDirectory)
///
/// if set to true [enable debug].
///
- public static void set_logging_level_debug_when_debug(bool enableDebug)
+ /// Logger, such as a verbose logger, to exclude from this.
+ public static void set_logging_level_debug_when_debug(bool enableDebug, string excludeLoggerName)
{
if (enableDebug)
{
@@ -121,8 +123,9 @@ public static void set_logging_level_debug_when_debug(bool enableDebug)
{
logger.Level = Level.Debug;
}
- }
- foreach (var append in logRepository.GetAppenders())
+ }
+
+ foreach (var append in logRepository.GetAppenders().Where(a => !a.Name.is_equal_to(excludeLoggerName.to_string())).or_empty_list_if_null())
{
var appender = append as AppenderSkeleton;
if (appender != null)
@@ -140,8 +143,9 @@ public static void set_logging_level_debug_when_debug(bool enableDebug)
///
/// if set to true [enable verbose].
///
+ /// If debug is also enabled
/// Name of the verbose logger.
- public static void set_verbose_logger_when_verbose(bool enableVerbose, string verboseLoggerName)
+ public static void set_verbose_logger_when_verbose(bool enableVerbose,bool enableDebug, string verboseLoggerName)
{
if (enableVerbose)
{
@@ -153,7 +157,8 @@ public static void set_verbose_logger_when_verbose(bool enableVerbose, string ve
if (appender != null && appender.Name.is_equal_to(verboseLoggerName))
{
appender.ClearFilters();
- appender.AddFilter( new log4net.Filter.LevelRangeFilter {LevelMin = Level.Info, LevelMax = Level.Fatal});
+ var minLevel = enableDebug ? Level.Debug : Level.Info;
+ appender.AddFilter(new log4net.Filter.LevelRangeFilter { LevelMin = minLevel, LevelMax = Level.Fatal });
}
}