File tree Expand file tree Collapse file tree 4 files changed +27
-16
lines changed
java/org/springframework/bootstrap
resources/org/springframework/bootstrap/logging/logback
test/java/org/springframework/bootstrap Expand file tree Collapse file tree 4 files changed +27
-16
lines changed Original file line number Diff line number Diff line change @@ -347,8 +347,11 @@ protected void applyInitializers(ConfigurableApplicationContext context) {
347
347
}
348
348
349
349
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
+ }
352
355
}
353
356
354
357
/**
Original file line number Diff line number Diff line change @@ -46,20 +46,32 @@ public StartupInfoLogger(Class<?> sourceClass) {
46
46
47
47
public void log (Log log ) {
48
48
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 () {
49
58
StringBuilder message = new StringBuilder ();
50
59
message .append ("Starting " );
51
60
message .append (getApplicationName ());
52
61
message .append (getVersion (this .sourceClass ));
53
62
message .append (getOn ());
54
63
message .append (getPid ());
55
64
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 ();
58
70
message .append ("Running with Spring Bootstrap" );
59
71
message .append (getVersion (SpringApplication .class ));
60
72
message .append (", Spring" );
61
73
message .append (getVersion (ApplicationContext .class ));
62
- log . info ( message ) ;
74
+ return message ;
63
75
}
64
76
65
77
private String getApplicationName () {
Original file line number Diff line number Diff line change 32
32
<appender-ref ref =" CONSOLE" />
33
33
<appender-ref ref =" FILE" />
34
34
</root >
35
-
35
+
36
36
<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" />
37
39
</configuration >
Original file line number Diff line number Diff line change 22
22
import static org .junit .Assert .assertTrue ;
23
23
24
24
/**
25
+ * Tests for {@link StartupInfoLogger}.
26
+ *
25
27
* @author Dave Syer
26
28
*/
27
- public class StartUpLoggerInfoTests {
29
+ public class StartUpLoggerTests {
28
30
29
31
private StringBuffer output = new StringBuffer ();
30
32
31
33
private SimpleLog log = new SimpleLog ("test" ) {
32
34
@ Override
33
35
protected void write (StringBuffer buffer ) {
34
- StartUpLoggerInfoTests .this .output .append (buffer ).append ("\n " );
36
+ StartUpLoggerTests .this .output .append (buffer ).append ("\n " );
35
37
};
36
38
};
37
39
@@ -40,14 +42,6 @@ public void sourceClassIncluded() {
40
42
new StartupInfoLogger (getClass ()).log (this .log );
41
43
assertTrue ("Wrong output: " + this .output ,
42
44
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" ));
51
45
}
52
46
53
47
}
You can’t perform that action at this time.
0 commit comments