Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
13272210
Commit
13272210
authored
Jul 24, 2013
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turn down logging
parent
da07cdf4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
16 deletions
+27
-16
SpringApplication.java
...java/org/springframework/bootstrap/SpringApplication.java
+5
-2
StartupInfoLogger.java
...java/org/springframework/bootstrap/StartupInfoLogger.java
+15
-3
logback.xml
...org/springframework/bootstrap/logging/logback/logback.xml
+3
-1
StartUpLoggerTests.java
...ava/org/springframework/bootstrap/StartUpLoggerTests.java
+4
-10
No files found.
spring-bootstrap/src/main/java/org/springframework/bootstrap/SpringApplication.java
View file @
13272210
...
@@ -347,8 +347,11 @@ public class SpringApplication {
...
@@ -347,8 +347,11 @@ public class SpringApplication {
}
}
protected
void
logStartupInfo
()
{
protected
void
logStartupInfo
()
{
new
StartupInfoLogger
(
this
.
mainApplicationClass
).
log
(
getApplicationLog
());
Log
applicationLog
=
getApplicationLog
();
getApplicationLog
().
info
(
"Sources: "
+
this
.
sources
);
new
StartupInfoLogger
(
this
.
mainApplicationClass
).
log
(
applicationLog
);
if
(
applicationLog
.
isDebugEnabled
())
{
applicationLog
.
debug
(
"Sources: "
+
this
.
sources
);
}
}
}
/**
/**
...
...
spring-bootstrap/src/main/java/org/springframework/bootstrap/StartupInfoLogger.java
View file @
13272210
...
@@ -46,6 +46,15 @@ class StartupInfoLogger {
...
@@ -46,6 +46,15 @@ class StartupInfoLogger {
public
void
log
(
Log
log
)
{
public
void
log
(
Log
log
)
{
Assert
.
notNull
(
log
,
"Log must not be null"
);
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
();
StringBuilder
message
=
new
StringBuilder
();
message
.
append
(
"Starting "
);
message
.
append
(
"Starting "
);
message
.
append
(
getApplicationName
());
message
.
append
(
getApplicationName
());
...
@@ -53,13 +62,16 @@ class StartupInfoLogger {
...
@@ -53,13 +62,16 @@ class StartupInfoLogger {
message
.
append
(
getOn
());
message
.
append
(
getOn
());
message
.
append
(
getPid
());
message
.
append
(
getPid
());
message
.
append
(
getContext
());
message
.
append
(
getContext
());
log
.
info
(
message
);
return
message
.
toString
();
message
.
setLength
(
0
);
}
private
StringBuilder
getRunningMessage
()
{
StringBuilder
message
=
new
StringBuilder
();
message
.
append
(
"Running with Spring Bootstrap"
);
message
.
append
(
"Running with Spring Bootstrap"
);
message
.
append
(
getVersion
(
SpringApplication
.
class
));
message
.
append
(
getVersion
(
SpringApplication
.
class
));
message
.
append
(
", Spring"
);
message
.
append
(
", Spring"
);
message
.
append
(
getVersion
(
ApplicationContext
.
class
));
message
.
append
(
getVersion
(
ApplicationContext
.
class
));
log
.
info
(
message
)
;
return
message
;
}
}
private
String
getApplicationName
()
{
private
String
getApplicationName
()
{
...
...
spring-bootstrap/src/main/resources/org/springframework/bootstrap/logging/logback/logback.xml
View file @
13272210
...
@@ -32,6 +32,8 @@
...
@@ -32,6 +32,8 @@
<appender-ref
ref=
"CONSOLE"
/>
<appender-ref
ref=
"CONSOLE"
/>
<appender-ref
ref=
"FILE"
/>
<appender-ref
ref=
"FILE"
/>
</root>
</root>
<logger
name=
"org.hibernate.validator.internal.util.Version"
level=
"WARN"
/>
<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>
</configuration>
spring-bootstrap/src/test/java/org/springframework/bootstrap/StartUpLogger
Info
Tests.java
→
spring-bootstrap/src/test/java/org/springframework/bootstrap/StartUpLoggerTests.java
View file @
13272210
...
@@ -22,16 +22,18 @@ import org.junit.Test;
...
@@ -22,16 +22,18 @@ import org.junit.Test;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
/**
* Tests for {@link StartupInfoLogger}.
*
* @author Dave Syer
* @author Dave Syer
*/
*/
public
class
StartUpLogger
Info
Tests
{
public
class
StartUpLoggerTests
{
private
StringBuffer
output
=
new
StringBuffer
();
private
StringBuffer
output
=
new
StringBuffer
();
private
SimpleLog
log
=
new
SimpleLog
(
"test"
)
{
private
SimpleLog
log
=
new
SimpleLog
(
"test"
)
{
@Override
@Override
protected
void
write
(
StringBuffer
buffer
)
{
protected
void
write
(
StringBuffer
buffer
)
{
StartUpLogger
Info
Tests
.
this
.
output
.
append
(
buffer
).
append
(
"\n"
);
StartUpLoggerTests
.
this
.
output
.
append
(
buffer
).
append
(
"\n"
);
};
};
};
};
...
@@ -40,14 +42,6 @@ public class StartUpLoggerInfoTests {
...
@@ -40,14 +42,6 @@ public class StartUpLoggerInfoTests {
new
StartupInfoLogger
(
getClass
()).
log
(
this
.
log
);
new
StartupInfoLogger
(
getClass
()).
log
(
this
.
log
);
assertTrue
(
"Wrong output: "
+
this
.
output
,
assertTrue
(
"Wrong output: "
+
this
.
output
,
this
.
output
.
toString
().
contains
(
"Starting "
+
getClass
().
getSimpleName
()));
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"
));
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment