Turn down logging

pull/9/head
Phillip Webb 11 years ago
parent da07cdf41f
commit 132722100a

@ -347,8 +347,11 @@ public class SpringApplication {
}
protected void logStartupInfo() {
new StartupInfoLogger(this.mainApplicationClass).log(getApplicationLog());
getApplicationLog().info("Sources: " + this.sources);
Log applicationLog = getApplicationLog();
new StartupInfoLogger(this.mainApplicationClass).log(applicationLog);
if (applicationLog.isDebugEnabled()) {
applicationLog.debug("Sources: " + this.sources);
}
}
/**

@ -46,6 +46,15 @@ class StartupInfoLogger {
public void log(Log log) {
Assert.notNull(log, "Log must not be null");
if (log.isInfoEnabled()) {
log.info(getStartupMessage());
}
if (log.isDebugEnabled()) {
log.debug(getRunningMessage());
}
}
private String getStartupMessage() {
StringBuilder message = new StringBuilder();
message.append("Starting ");
message.append(getApplicationName());
@ -53,13 +62,16 @@ class StartupInfoLogger {
message.append(getOn());
message.append(getPid());
message.append(getContext());
log.info(message);
message.setLength(0);
return message.toString();
}
private StringBuilder getRunningMessage() {
StringBuilder message = new StringBuilder();
message.append("Running with Spring Bootstrap");
message.append(getVersion(SpringApplication.class));
message.append(", Spring");
message.append(getVersion(ApplicationContext.class));
log.info(message);
return message;
}
private String getApplicationName() {

@ -32,6 +32,8 @@
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
<logger name="org.hibernate.validator.internal.util.Version" level="WARN"/>
<logger name="org.apache.coyote.http11.Http11NioProtocol" level="WARN"/>
<logger name="org.apache.tomcat.util.net.NioSelectorPool" level="WARN"/>
</configuration>

@ -22,16 +22,18 @@ import org.junit.Test;
import static org.junit.Assert.assertTrue;
/**
* Tests for {@link StartupInfoLogger}.
*
* @author Dave Syer
*/
public class StartUpLoggerInfoTests {
public class StartUpLoggerTests {
private StringBuffer output = new StringBuffer();
private SimpleLog log = new SimpleLog("test") {
@Override
protected void write(StringBuffer buffer) {
StartUpLoggerInfoTests.this.output.append(buffer).append("\n");
StartUpLoggerTests.this.output.append(buffer).append("\n");
};
};
@ -40,14 +42,6 @@ public class StartUpLoggerInfoTests {
new StartupInfoLogger(getClass()).log(this.log);
assertTrue("Wrong output: " + this.output,
this.output.toString().contains("Starting " + getClass().getSimpleName()));
// System.err.println(this.output);
}
@Test
public void bootstrapVersionIncluded() {
new StartupInfoLogger(getClass()).log(this.log);
assertTrue("Wrong output: " + this.output,
this.output.toString().contains("Spring Bootstrap v"));
}
}
Loading…
Cancel
Save