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
222a09cf
Commit
222a09cf
authored
Jul 06, 2017
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make ROOT logger name case-insensitive when setting log level
Fixes gh-9693
parent
96b1a854
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
LoggingApplicationListener.java
...ingframework/boot/logging/LoggingApplicationListener.java
+10
-4
LoggingApplicationListenerTests.java
...amework/boot/logging/LoggingApplicationListenerTests.java
+14
-0
No files found.
spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java
View file @
222a09cf
...
...
@@ -341,17 +341,23 @@ public class LoggingApplicationListener implements GenericApplicationListener {
protected
void
setLogLevels
(
LoggingSystem
system
,
Environment
environment
)
{
Map
<
String
,
Object
>
levels
=
new
RelaxedPropertyResolver
(
environment
)
.
getSubProperties
(
"logging.level."
);
boolean
rootProcessed
=
false
;
for
(
Entry
<
String
,
Object
>
entry
:
levels
.
entrySet
())
{
setLogLevel
(
system
,
environment
,
entry
.
getKey
(),
entry
.
getValue
().
toString
());
String
name
=
entry
.
getKey
();
if
(
name
.
equalsIgnoreCase
(
LoggingSystem
.
ROOT_LOGGER_NAME
))
{
if
(
rootProcessed
)
{
return
;
}
name
=
null
;
rootProcessed
=
true
;
}
setLogLevel
(
system
,
environment
,
name
,
entry
.
getValue
().
toString
());
}
}
private
void
setLogLevel
(
LoggingSystem
system
,
Environment
environment
,
String
name
,
String
level
)
{
try
{
if
(
name
.
equalsIgnoreCase
(
LoggingSystem
.
ROOT_LOGGER_NAME
))
{
name
=
null
;
}
level
=
environment
.
resolvePlaceholders
(
level
);
system
.
setLogLevel
(
name
,
coerceLogLevel
(
level
));
}
...
...
spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java
View file @
222a09cf
...
...
@@ -18,6 +18,7 @@ package org.springframework.boot.logging;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -47,6 +48,8 @@ import org.springframework.context.ApplicationListener;
import
org.springframework.context.event.ContextClosedEvent
;
import
org.springframework.context.event.SimpleApplicationEventMulticaster
;
import
org.springframework.context.support.GenericApplicationContext
;
import
org.springframework.core.env.MapPropertySource
;
import
org.springframework.core.env.MutablePropertySources
;
import
org.springframework.test.context.support.TestPropertySourceUtils
;
import
org.springframework.test.util.ReflectionTestUtils
;
...
...
@@ -481,6 +484,17 @@ public class LoggingApplicationListenerTests {
assertThat
(
System
.
getProperty
(
"CONSOLE_LOG_PATTERN"
)).
isEqualTo
(
"console ${pid}"
);
}
@Test
public
void
lowPriorityPropertySourceShouldNotOverrideRootLoggerConfig
()
throws
Exception
{
MutablePropertySources
propertySources
=
this
.
context
.
getEnvironment
().
getPropertySources
();
propertySources
.
addFirst
(
new
MapPropertySource
(
"test1"
,
Collections
.<
String
,
Object
>
singletonMap
(
"logging.level.ROOT"
,
"DEBUG"
)));
propertySources
.
addLast
(
new
MapPropertySource
(
"test2"
,
Collections
.<
String
,
Object
>
singletonMap
(
"logging.level.root"
,
"WARN"
)));
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
context
.
getClassLoader
());
this
.
logger
.
debug
(
"testatdebug"
);
assertThat
(
this
.
outputCapture
.
toString
()).
contains
(
"testatdebug"
);
}
@Test
public
void
logFilePropertiesCanReferenceSystemProperties
()
{
TestPropertySourceUtils
.
addInlinedPropertiesToEnvironment
(
this
.
context
,
...
...
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