diff --git a/org.eclipse.m2e.logback/src/org/eclipse/m2e/logback/configuration/M2ELogbackConfigurator.java b/org.eclipse.m2e.logback/src/org/eclipse/m2e/logback/configuration/M2ELogbackConfigurator.java index 3d372af7c0..75cec03389 100644 --- a/org.eclipse.m2e.logback/src/org/eclipse/m2e/logback/configuration/M2ELogbackConfigurator.java +++ b/org.eclipse.m2e.logback/src/org/eclipse/m2e/logback/configuration/M2ELogbackConfigurator.java @@ -19,6 +19,7 @@ import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Arrays; import java.util.Map; import java.util.Map.Entry; import java.util.Properties; @@ -56,6 +57,9 @@ public class M2ELogbackConfigurator extends BasicConfigurator implements Configu // This has to match the log directory in defaultLogbackConfiguration/logback.xml private static final String PROPERTY_LOG_DIRECTORY = "org.eclipse.m2e.log.dir"; //$NON-NLS-1$ + // This has to match the log directory in defaultLogbackConfiguration/logback.xml + private static final String PROPERTY_LOG_CONSOLE_THRESHOLD = "org.eclipse.m2e.log.console.threshold"; //$NON-NLS-1$ + @Override public void configure(LoggerContext lc) { // Bug 337167: Configuring Logback requires the state-location. If not yet initialized it will be initialized to the default value, @@ -89,6 +93,11 @@ private synchronized void configureLogback(LoggerContext lc) { if(System.getProperty(PROPERTY_LOG_DIRECTORY, "").length() <= 0) { //$NON-NLS-1$ System.setProperty(PROPERTY_LOG_DIRECTORY, stateDir.toAbsolutePath().toString()); } + if(System.getProperty(PROPERTY_LOG_CONSOLE_THRESHOLD, "").length() <= 0) { //$NON-NLS-1$ + if(Arrays.stream(Platform.getCommandLineArgs()).filter(s -> s.equals("-consolelog")).findAny().isPresent()) { + System.setProperty(PROPERTY_LOG_CONSOLE_THRESHOLD, Level.DEBUG.levelStr); + } + } loadConfiguration(lc, configFile.toUri().toURL()); //Delete old logs in legacy logback plug-in's state location. Can sum up to 1GB of disk-space.