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
a07f0272
Commit
a07f0272
authored
Aug 28, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
04c3e997
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
17 deletions
+32
-17
LoggingApplicationListener.java
...ingframework/boot/logging/LoggingApplicationListener.java
+32
-17
No files found.
spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java
View file @
a07f0272
...
@@ -141,7 +141,19 @@ public class LoggingApplicationListener implements SmartApplicationListener {
...
@@ -141,7 +141,19 @@ public class LoggingApplicationListener implements SmartApplicationListener {
* {@link Environment} and the classpath.
* {@link Environment} and the classpath.
*/
*/
protected
void
initialize
(
ConfigurableEnvironment
environment
,
ClassLoader
classLoader
)
{
protected
void
initialize
(
ConfigurableEnvironment
environment
,
ClassLoader
classLoader
)
{
initializeEarlyLoggingLevel
(
environment
);
cleanLogTempProperty
();
LoggingSystem
system
=
LoggingSystem
.
get
(
classLoader
);
boolean
systemEnvironmentChanged
=
mapSystemPropertiesFromSpring
(
environment
);
if
(
systemEnvironmentChanged
)
{
// Re-initialize the defaults in case the system Environment changed
system
.
beforeInitialize
();
}
initializeSystem
(
environment
,
system
);
initializeFinalLoggingLevels
(
environment
,
system
);
}
private
void
initializeEarlyLoggingLevel
(
ConfigurableEnvironment
environment
)
{
if
(
this
.
parseArgs
&&
this
.
springBootLogging
==
null
)
{
if
(
this
.
parseArgs
&&
this
.
springBootLogging
==
null
)
{
if
(
environment
.
containsProperty
(
"debug"
))
{
if
(
environment
.
containsProperty
(
"debug"
))
{
this
.
springBootLogging
=
LogLevel
.
DEBUG
;
this
.
springBootLogging
=
LogLevel
.
DEBUG
;
...
@@ -150,7 +162,9 @@ public class LoggingApplicationListener implements SmartApplicationListener {
...
@@ -150,7 +162,9 @@ public class LoggingApplicationListener implements SmartApplicationListener {
this
.
springBootLogging
=
LogLevel
.
TRACE
;
this
.
springBootLogging
=
LogLevel
.
TRACE
;
}
}
}
}
}
private
void
cleanLogTempProperty
()
{
// Logback won't read backslashes so add a clean path for it to use
// Logback won't read backslashes so add a clean path for it to use
if
(!
StringUtils
.
hasLength
(
System
.
getProperty
(
"LOG_TEMP"
)))
{
if
(!
StringUtils
.
hasLength
(
System
.
getProperty
(
"LOG_TEMP"
)))
{
String
path
=
System
.
getProperty
(
"java.io.tmpdir"
);
String
path
=
System
.
getProperty
(
"java.io.tmpdir"
);
...
@@ -160,24 +174,24 @@ public class LoggingApplicationListener implements SmartApplicationListener {
...
@@ -160,24 +174,24 @@ public class LoggingApplicationListener implements SmartApplicationListener {
}
}
System
.
setProperty
(
"LOG_TEMP"
,
path
);
System
.
setProperty
(
"LOG_TEMP"
,
path
);
}
}
}
boolean
environmentChanged
=
false
;
private
boolean
mapSystemPropertiesFromSpring
(
Environment
environment
)
{
boolean
changed
=
false
;
for
(
Map
.
Entry
<
String
,
String
>
mapping
:
ENVIRONMENT_SYSTEM_PROPERTY_MAPPING
for
(
Map
.
Entry
<
String
,
String
>
mapping
:
ENVIRONMENT_SYSTEM_PROPERTY_MAPPING
.
entrySet
())
{
.
entrySet
())
{
if
(
environment
.
containsProperty
(
mapping
.
getKey
()))
{
String
springName
=
mapping
.
getKey
();
System
.
setProperty
(
mapping
.
getValue
(),
String
systemName
=
mapping
.
getValue
();
environment
.
getProperty
(
mapping
.
getKey
()));
if
(
environment
.
containsProperty
(
springName
))
{
environmentChanged
=
true
;
System
.
setProperty
(
systemName
,
environment
.
getProperty
(
springName
));
changed
=
true
;
}
}
}
}
return
changed
;
}
LoggingSystem
system
=
LoggingSystem
.
get
(
classLoader
);
private
void
initializeSystem
(
ConfigurableEnvironment
environment
,
LoggingSystem
system
)
{
if
(
environmentChanged
)
{
// Re-initialize the defaults in case the Environment changed
system
.
beforeInitialize
();
}
// User specified configuration
if
(
environment
.
containsProperty
(
"logging.config"
))
{
if
(
environment
.
containsProperty
(
"logging.config"
))
{
String
value
=
environment
.
getProperty
(
"logging.config"
);
String
value
=
environment
.
getProperty
(
"logging.config"
);
try
{
try
{
...
@@ -185,22 +199,23 @@ public class LoggingApplicationListener implements SmartApplicationListener {
...
@@ -185,22 +199,23 @@ public class LoggingApplicationListener implements SmartApplicationListener {
system
.
initialize
(
value
);
system
.
initialize
(
value
);
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
this
.
logger
this
.
logger
.
warn
(
"Logging environment value '"
+
value
.
warn
(
"Logging environment value '"
+
"' cannot be opened and will be ignored "
+
value
+
"(using default location instead)"
);
+
"' cannot be opened and will be ignored (using default location instead)"
);
system
.
initialize
();
system
.
initialize
();
}
}
}
}
else
{
else
{
system
.
initialize
();
system
.
initialize
();
}
}
}
private
void
initializeFinalLoggingLevels
(
ConfigurableEnvironment
environment
,
LoggingSystem
system
)
{
if
(
this
.
springBootLogging
!=
null
)
{
if
(
this
.
springBootLogging
!=
null
)
{
initializeLogLevel
(
system
,
this
.
springBootLogging
);
initializeLogLevel
(
system
,
this
.
springBootLogging
);
}
}
setLogLevels
(
system
,
environment
);
setLogLevels
(
system
,
environment
);
}
}
public
void
setLogLevels
(
LoggingSystem
system
,
Environment
environment
)
{
public
void
setLogLevels
(
LoggingSystem
system
,
Environment
environment
)
{
...
...
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