Skip to content

Commit 1327221

Browse files
committed
Turn down logging
1 parent da07cdf commit 1327221

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

spring-bootstrap/src/main/java/org/springframework/bootstrap/SpringApplication.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,11 @@ protected void applyInitializers(ConfigurableApplicationContext context) {
347347
}
348348

349349
protected void logStartupInfo() {
350-
new StartupInfoLogger(this.mainApplicationClass).log(getApplicationLog());
351-
getApplicationLog().info("Sources: " + this.sources);
350+
Log applicationLog = getApplicationLog();
351+
new StartupInfoLogger(this.mainApplicationClass).log(applicationLog);
352+
if (applicationLog.isDebugEnabled()) {
353+
applicationLog.debug("Sources: " + this.sources);
354+
}
352355
}
353356

354357
/**

spring-bootstrap/src/main/java/org/springframework/bootstrap/StartupInfoLogger.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,32 @@ public StartupInfoLogger(Class<?> sourceClass) {
4646

4747
public void log(Log log) {
4848
Assert.notNull(log, "Log must not be null");
49+
if (log.isInfoEnabled()) {
50+
log.info(getStartupMessage());
51+
}
52+
if (log.isDebugEnabled()) {
53+
log.debug(getRunningMessage());
54+
}
55+
}
56+
57+
private String getStartupMessage() {
4958
StringBuilder message = new StringBuilder();
5059
message.append("Starting ");
5160
message.append(getApplicationName());
5261
message.append(getVersion(this.sourceClass));
5362
message.append(getOn());
5463
message.append(getPid());
5564
message.append(getContext());
56-
log.info(message);
57-
message.setLength(0);
65+
return message.toString();
66+
}
67+
68+
private StringBuilder getRunningMessage() {
69+
StringBuilder message = new StringBuilder();
5870
message.append("Running with Spring Bootstrap");
5971
message.append(getVersion(SpringApplication.class));
6072
message.append(", Spring");
6173
message.append(getVersion(ApplicationContext.class));
62-
log.info(message);
74+
return message;
6375
}
6476

6577
private String getApplicationName() {

spring-bootstrap/src/main/resources/org/springframework/bootstrap/logging/logback/logback.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
<appender-ref ref="CONSOLE" />
3333
<appender-ref ref="FILE" />
3434
</root>
35-
35+
3636
<logger name="org.hibernate.validator.internal.util.Version" level="WARN"/>
37+
<logger name="org.apache.coyote.http11.Http11NioProtocol" level="WARN"/>
38+
<logger name="org.apache.tomcat.util.net.NioSelectorPool" level="WARN"/>
3739
</configuration>

spring-bootstrap/src/test/java/org/springframework/bootstrap/StartUpLoggerInfoTests.java renamed to spring-bootstrap/src/test/java/org/springframework/bootstrap/StartUpLoggerTests.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@
2222
import static org.junit.Assert.assertTrue;
2323

2424
/**
25+
* Tests for {@link StartupInfoLogger}.
26+
*
2527
* @author Dave Syer
2628
*/
27-
public class StartUpLoggerInfoTests {
29+
public class StartUpLoggerTests {
2830

2931
private StringBuffer output = new StringBuffer();
3032

3133
private SimpleLog log = new SimpleLog("test") {
3234
@Override
3335
protected void write(StringBuffer buffer) {
34-
StartUpLoggerInfoTests.this.output.append(buffer).append("\n");
36+
StartUpLoggerTests.this.output.append(buffer).append("\n");
3537
};
3638
};
3739

@@ -40,14 +42,6 @@ public void sourceClassIncluded() {
4042
new StartupInfoLogger(getClass()).log(this.log);
4143
assertTrue("Wrong output: " + this.output,
4244
this.output.toString().contains("Starting " + getClass().getSimpleName()));
43-
// System.err.println(this.output);
44-
}
45-
46-
@Test
47-
public void bootstrapVersionIncluded() {
48-
new StartupInfoLogger(getClass()).log(this.log);
49-
assertTrue("Wrong output: " + this.output,
50-
this.output.toString().contains("Spring Bootstrap v"));
5145
}
5246

5347
}

0 commit comments

Comments
 (0)