Skip to content

Commit 54a23f9

Browse files
author
Dave Syer
committed
Make -q and -v do something more sensible
-q switches off all logging and the banner, -v switches logging to debug, running with neither will be info. Fixes gh-1108
1 parent 93c0f6f commit 54a23f9

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

spring-boot-cli/src/main/java/org/springframework/boot/cli/command/run/SpringApplicationRunner.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,17 @@ public SpringApplicationRunner(
6767
this.sources = sources.clone();
6868
this.args = args.clone();
6969
this.compiler = new GroovyCompiler(configuration);
70-
if (configuration.getLogLevel().intValue() <= Level.FINE.intValue()) {
70+
int level = configuration.getLogLevel().intValue();
71+
if (level <= Level.FINER.intValue()) {
7172
System.setProperty("groovy.grape.report.downloads", "true");
73+
System.setProperty("trace", "true");
74+
}
75+
else if (level <= Level.FINE.intValue()) {
76+
System.setProperty("debug", "true");
77+
}
78+
else if (level == Level.OFF.intValue()) {
79+
System.setProperty("spring.main.showBanner", "false");
80+
System.setProperty("logging.level.ROOT", "OFF");
7281
}
7382
}
7483

spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,17 @@ public void setLogLevels(LoggingSystem system, Environment environment) {
206206
Map<String, Object> levels = new RelaxedPropertyResolver(environment)
207207
.getSubProperties("logging.level.");
208208
for (Entry<String, Object> entry : levels.entrySet()) {
209+
String name = entry.getKey();
209210
try {
210211
LogLevel level = LogLevel.valueOf(entry.getValue().toString());
211-
system.setLogLevel(entry.getKey(), level);
212+
if (name.equalsIgnoreCase("root")) {
213+
name = null;
214+
}
215+
system.setLogLevel(name, level);
212216
}
213217
catch (RuntimeException e) {
214218
this.logger.error("Cannot set level: " + entry.getValue() + " for '"
215-
+ entry.getKey() + "'");
219+
+ name + "'");
216220
}
217221
}
218222
}

0 commit comments

Comments
 (0)