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
7031a3b1
Commit
7031a3b1
authored
Jan 14, 2020
by
Scott Frederick
Committed by
Stephane Nicoll
Jan 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove deprecated logging properties
See gh-19699
parent
421c464d
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
22 additions
and
178 deletions
+22
-178
LogFileWebEndpointAutoConfiguration.java
...onfigure/logging/LogFileWebEndpointAutoConfiguration.java
+5
-10
LogFileWebEndpointAutoConfigurationTests.java
...ure/logging/LogFileWebEndpointAutoConfigurationTests.java
+1
-17
LogFileWebEndpointTests.java
...amework/boot/actuate/logging/LogFileWebEndpointTests.java
+1
-11
LogFileWebEndpointWebIntegrationTests.java
...ctuate/logging/LogFileWebEndpointWebIntegrationTests.java
+2
-2
LoggingApplicationListener.java
...work/boot/context/logging/LoggingApplicationListener.java
+2
-36
LogFile.java
...c/main/java/org/springframework/boot/logging/LogFile.java
+3
-28
additional-spring-configuration-metadata.json
...es/META-INF/additional-spring-configuration-metadata.json
+4
-2
LoggingApplicationListenerIntegrationTests.java
...t/logging/LoggingApplicationListenerIntegrationTests.java
+2
-2
LoggingApplicationListenerTests.java
...boot/context/logging/LoggingApplicationListenerTests.java
+1
-45
LogFileTests.java
...t/java/org/springframework/boot/logging/LogFileTests.java
+1
-25
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java
View file @
7031a3b1
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -56,16 +56,15 @@ public class LogFileWebEndpointAutoConfiguration {
...
@@ -56,16 +56,15 @@ public class LogFileWebEndpointAutoConfiguration {
private
static
class
LogFileCondition
extends
SpringBootCondition
{
private
static
class
LogFileCondition
extends
SpringBootCondition
{
@SuppressWarnings
(
"deprecation"
)
@Override
@Override
public
ConditionOutcome
getMatchOutcome
(
ConditionContext
context
,
AnnotatedTypeMetadata
metadata
)
{
public
ConditionOutcome
getMatchOutcome
(
ConditionContext
context
,
AnnotatedTypeMetadata
metadata
)
{
Environment
environment
=
context
.
getEnvironment
();
Environment
environment
=
context
.
getEnvironment
();
String
config
=
getLogFileConfig
(
environment
,
LogFile
.
FILE_NAME_PROPERTY
,
LogFile
.
FILE_PROPERTY
);
String
config
=
getLogFileConfig
(
environment
,
LogFile
.
FILE_NAME_PROPERTY
);
ConditionMessage
.
Builder
message
=
ConditionMessage
.
forCondition
(
"Log File"
);
ConditionMessage
.
Builder
message
=
ConditionMessage
.
forCondition
(
"Log File"
);
if
(
StringUtils
.
hasText
(
config
))
{
if
(
StringUtils
.
hasText
(
config
))
{
return
ConditionOutcome
.
match
(
message
.
found
(
LogFile
.
FILE_NAME_PROPERTY
).
items
(
config
));
return
ConditionOutcome
.
match
(
message
.
found
(
LogFile
.
FILE_NAME_PROPERTY
).
items
(
config
));
}
}
config
=
getLogFileConfig
(
environment
,
LogFile
.
FILE_PATH_PROPERTY
,
LogFile
.
PATH_PROPERTY
);
config
=
getLogFileConfig
(
environment
,
LogFile
.
FILE_PATH_PROPERTY
);
if
(
StringUtils
.
hasText
(
config
))
{
if
(
StringUtils
.
hasText
(
config
))
{
return
ConditionOutcome
.
match
(
message
.
found
(
LogFile
.
FILE_PATH_PROPERTY
).
items
(
config
));
return
ConditionOutcome
.
match
(
message
.
found
(
LogFile
.
FILE_PATH_PROPERTY
).
items
(
config
));
}
}
...
@@ -76,12 +75,8 @@ public class LogFileWebEndpointAutoConfiguration {
...
@@ -76,12 +75,8 @@ public class LogFileWebEndpointAutoConfiguration {
return
ConditionOutcome
.
noMatch
(
message
.
didNotFind
(
"logging file"
).
atAll
());
return
ConditionOutcome
.
noMatch
(
message
.
didNotFind
(
"logging file"
).
atAll
());
}
}
private
String
getLogFileConfig
(
Environment
environment
,
String
configName
,
String
deprecatedConfigName
)
{
private
String
getLogFileConfig
(
Environment
environment
,
String
configName
)
{
String
config
=
environment
.
resolvePlaceholders
(
"${"
+
configName
+
":}"
);
return
environment
.
resolvePlaceholders
(
"${"
+
configName
+
":}"
);
if
(
StringUtils
.
hasText
(
config
))
{
return
config
;
}
return
environment
.
resolvePlaceholders
(
"${"
+
deprecatedConfigName
+
":}"
);
}
}
}
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfigurationTests.java
View file @
7031a3b1
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -64,14 +64,6 @@ class LogFileWebEndpointAutoConfigurationTests {
...
@@ -64,14 +64,6 @@ class LogFileWebEndpointAutoConfigurationTests {
.
run
((
context
)
->
assertThat
(
context
).
hasSingleBean
(
LogFileWebEndpoint
.
class
));
.
run
((
context
)
->
assertThat
(
context
).
hasSingleBean
(
LogFileWebEndpoint
.
class
));
}
}
@Test
@Deprecated
void
runWhenLoggingFileIsSetWithDeprecatedPropertyAndExposedShouldHaveEndpointBean
()
{
this
.
contextRunner
.
withPropertyValues
(
"logging.file:test.log"
,
"management.endpoints.web.exposure.include=logfile"
)
.
run
((
context
)
->
assertThat
(
context
).
hasSingleBean
(
LogFileWebEndpoint
.
class
));
}
@Test
@Test
void
runWhenLoggingPathIsSetAndNotExposedShouldNotHaveEndpointBean
()
{
void
runWhenLoggingPathIsSetAndNotExposedShouldNotHaveEndpointBean
()
{
this
.
contextRunner
.
withPropertyValues
(
"logging.file.path:test/logs"
)
this
.
contextRunner
.
withPropertyValues
(
"logging.file.path:test/logs"
)
...
@@ -85,14 +77,6 @@ class LogFileWebEndpointAutoConfigurationTests {
...
@@ -85,14 +77,6 @@ class LogFileWebEndpointAutoConfigurationTests {
.
run
((
context
)
->
assertThat
(
context
).
hasSingleBean
(
LogFileWebEndpoint
.
class
));
.
run
((
context
)
->
assertThat
(
context
).
hasSingleBean
(
LogFileWebEndpoint
.
class
));
}
}
@Test
@Deprecated
void
runWhenLoggingPathIsSetWithDeprecatedPropertyAndExposedShouldHaveEndpointBean
()
{
this
.
contextRunner
.
withPropertyValues
(
"logging.path:test/logs"
,
"management.endpoints.web.exposure.include=logfile"
)
.
run
((
context
)
->
assertThat
(
context
).
hasSingleBean
(
LogFileWebEndpoint
.
class
));
}
@Test
@Test
void
logFileWebEndpointIsAutoConfiguredWhenExternalFileIsSet
()
{
void
logFileWebEndpointIsAutoConfiguredWhenExternalFileIsSet
()
{
this
.
contextRunner
this
.
contextRunner
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LogFileWebEndpointTests.java
View file @
7031a3b1
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -74,16 +74,6 @@ class LogFileWebEndpointTests {
...
@@ -74,16 +74,6 @@ class LogFileWebEndpointTests {
assertThat
(
contentOf
(
resource
.
getFile
())).
isEqualTo
(
"--TEST--"
);
assertThat
(
contentOf
(
resource
.
getFile
())).
isEqualTo
(
"--TEST--"
);
}
}
@Test
@Deprecated
void
resourceResponseWithLogFileAndDeprecatedProperty
()
throws
Exception
{
this
.
environment
.
setProperty
(
"logging.file"
,
this
.
logFile
.
getAbsolutePath
());
LogFileWebEndpoint
endpoint
=
new
LogFileWebEndpoint
(
LogFile
.
get
(
this
.
environment
),
null
);
Resource
resource
=
endpoint
.
logFile
();
assertThat
(
resource
).
isNotNull
();
assertThat
(
contentOf
(
resource
.
getFile
())).
isEqualTo
(
"--TEST--"
);
}
@Test
@Test
void
resourceResponseWithExternalLogFile
()
throws
Exception
{
void
resourceResponseWithExternalLogFile
()
throws
Exception
{
LogFileWebEndpoint
endpoint
=
new
LogFileWebEndpoint
(
null
,
this
.
logFile
);
LogFileWebEndpoint
endpoint
=
new
LogFileWebEndpoint
(
null
,
this
.
logFile
);
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LogFileWebEndpointWebIntegrationTests.java
View file @
7031a3b1
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -74,7 +74,7 @@ class LogFileWebEndpointWebIntegrationTests {
...
@@ -74,7 +74,7 @@ class LogFileWebEndpointWebIntegrationTests {
File
logFile
=
new
File
(
tempFile
,
"test.log"
);
File
logFile
=
new
File
(
tempFile
,
"test.log"
);
FileCopyUtils
.
copy
(
"--TEST--"
.
getBytes
(),
logFile
);
FileCopyUtils
.
copy
(
"--TEST--"
.
getBytes
(),
logFile
);
MockEnvironment
environment
=
new
MockEnvironment
();
MockEnvironment
environment
=
new
MockEnvironment
();
environment
.
setProperty
(
"logging.file"
,
logFile
.
getAbsolutePath
());
environment
.
setProperty
(
"logging.file
.name
"
,
logFile
.
getAbsolutePath
());
return
new
LogFileWebEndpoint
(
LogFile
.
get
(
environment
),
null
);
return
new
LogFileWebEndpoint
(
LogFile
.
get
(
environment
),
null
);
}
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java
View file @
7031a3b1
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -136,13 +136,6 @@ public class LoggingApplicationListener implements GenericApplicationListener {
...
@@ -136,13 +136,6 @@ public class LoggingApplicationListener implements GenericApplicationListener {
*/
*/
public
static
final
String
LOGGER_GROUPS_BEAN_NAME
=
"springBootLoggerGroups"
;
public
static
final
String
LOGGER_GROUPS_BEAN_NAME
=
"springBootLoggerGroups"
;
/**
* The name of the {@link LogFile} bean.
* @deprecated since 2.2.0 in favor of {@link #LOG_FILE_BEAN_NAME}
*/
@Deprecated
public
static
final
String
LOGFILE_BEAN_NAME
=
LOG_FILE_BEAN_NAME
;
private
static
final
Map
<
String
,
List
<
String
>>
DEFAULT_GROUP_LOGGERS
;
private
static
final
Map
<
String
,
List
<
String
>>
DEFAULT_GROUP_LOGGERS
;
static
{
static
{
MultiValueMap
<
String
,
String
>
loggers
=
new
LinkedMultiValueMap
<>();
MultiValueMap
<
String
,
String
>
loggers
=
new
LinkedMultiValueMap
<>();
...
@@ -333,7 +326,7 @@ public class LoggingApplicationListener implements GenericApplicationListener {
...
@@ -333,7 +326,7 @@ public class LoggingApplicationListener implements GenericApplicationListener {
private
void
initializeFinalLoggingLevels
(
ConfigurableEnvironment
environment
,
LoggingSystem
system
)
{
private
void
initializeFinalLoggingLevels
(
ConfigurableEnvironment
environment
,
LoggingSystem
system
)
{
bindLoggerGroups
(
environment
);
bindLoggerGroups
(
environment
);
if
(
this
.
springBootLogging
!=
null
)
{
if
(
this
.
springBootLogging
!=
null
)
{
initialize
LogLevel
(
system
,
this
.
springBootLogging
);
initialize
SpringBootLogging
(
system
,
this
.
springBootLogging
);
}
}
setLogLevels
(
system
,
environment
);
setLogLevels
(
system
,
environment
);
}
}
...
@@ -345,19 +338,6 @@ public class LoggingApplicationListener implements GenericApplicationListener {
...
@@ -345,19 +338,6 @@ public class LoggingApplicationListener implements GenericApplicationListener {
}
}
}
}
/**
* Initialize loggers based on the {@link #setSpringBootLogging(LogLevel)
* springBootLogging} setting.
* @param system the logging system
* @param springBootLogging the spring boot logging level requested
* @deprecated since 2.2.0 in favor of
* {@link #initializeSpringBootLogging(LoggingSystem, LogLevel)}
*/
@Deprecated
protected
void
initializeLogLevel
(
LoggingSystem
system
,
LogLevel
springBootLogging
)
{
initializeSpringBootLogging
(
system
,
springBootLogging
);
}
/**
/**
* Initialize loggers based on the {@link #setSpringBootLogging(LogLevel)
* Initialize loggers based on the {@link #setSpringBootLogging(LogLevel)
* springBootLogging} setting. By default this implementation will pick an appropriate
* springBootLogging} setting. By default this implementation will pick an appropriate
...
@@ -372,20 +352,6 @@ public class LoggingApplicationListener implements GenericApplicationListener {
...
@@ -372,20 +352,6 @@ public class LoggingApplicationListener implements GenericApplicationListener {
.
forEach
((
name
)
->
configureLogLevel
(
name
,
springBootLogging
,
configurer
));
.
forEach
((
name
)
->
configureLogLevel
(
name
,
springBootLogging
,
configurer
));
}
}
/**
* Set logging levels based on relevant {@link Environment} properties.
* @param system the logging system
* @param environment the environment
* @deprecated since 2.2.0 in favor of
* {@link #setLogLevels(LoggingSystem, ConfigurableEnvironment)}
*/
@Deprecated
protected
void
setLogLevels
(
LoggingSystem
system
,
Environment
environment
)
{
if
(
environment
instanceof
ConfigurableEnvironment
)
{
setLogLevels
(
system
,
(
ConfigurableEnvironment
)
environment
);
}
}
/**
/**
* Set logging levels based on relevant {@link Environment} properties.
* Set logging levels based on relevant {@link Environment} properties.
* @param system the logging system
* @param system the logging system
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java
View file @
7031a3b1
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -37,22 +37,6 @@ import org.springframework.util.StringUtils;
...
@@ -37,22 +37,6 @@ import org.springframework.util.StringUtils;
*/
*/
public
class
LogFile
{
public
class
LogFile
{
/**
* The name of the Spring property that contains the name of the log file. Names can
* be an exact location or relative to the current directory.
* @deprecated since 2.2.0 in favor of {@link #FILE_NAME_PROPERTY}
*/
@Deprecated
public
static
final
String
FILE_PROPERTY
=
"logging.file"
;
/**
* The name of the Spring property that contains the directory where log files are
* written.
* @deprecated since 2.2.0 in favor of {@link #FILE_PATH_PROPERTY}
*/
@Deprecated
public
static
final
String
PATH_PROPERTY
=
"logging.path"
;
/**
/**
* The name of the Spring property that contains the name of the log file. Names can
* The name of the Spring property that contains the name of the log file. Names can
* be an exact location or relative to the current directory.
* be an exact location or relative to the current directory.
...
@@ -128,21 +112,12 @@ public class LogFile {
...
@@ -128,21 +112,12 @@ public class LogFile {
* suitable properties
* suitable properties
*/
*/
public
static
LogFile
get
(
PropertyResolver
propertyResolver
)
{
public
static
LogFile
get
(
PropertyResolver
propertyResolver
)
{
String
file
=
getLogFileProperty
(
propertyResolver
,
FILE_NAME_PROPERTY
,
FIL
E_PROPERTY
);
String
file
=
propertyResolver
.
getProperty
(
FILE_NAM
E_PROPERTY
);
String
path
=
getLogFileProperty
(
propertyResolver
,
FILE_PATH_PROPERTY
,
PATH_PROPERTY
);
String
path
=
propertyResolver
.
getProperty
(
FILE_
PATH_PROPERTY
);
if
(
StringUtils
.
hasLength
(
file
)
||
StringUtils
.
hasLength
(
path
))
{
if
(
StringUtils
.
hasLength
(
file
)
||
StringUtils
.
hasLength
(
path
))
{
return
new
LogFile
(
file
,
path
);
return
new
LogFile
(
file
,
path
);
}
}
return
null
;
return
null
;
}
}
private
static
String
getLogFileProperty
(
PropertyResolver
propertyResolver
,
String
propertyName
,
String
deprecatedPropertyName
)
{
String
property
=
propertyResolver
.
getProperty
(
propertyName
);
if
(
property
!=
null
)
{
return
property
;
}
return
propertyResolver
.
getProperty
(
deprecatedPropertyName
);
}
}
}
spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json
View file @
7031a3b1
...
@@ -85,7 +85,8 @@
...
@@ -85,7 +85,8 @@
"description"
:
"Log file name (for instance, `myapp.log`). Names can be an exact location or relative to the current directory."
,
"description"
:
"Log file name (for instance, `myapp.log`). Names can be an exact location or relative to the current directory."
,
"sourceType"
:
"org.springframework.boot.context.logging.LoggingApplicationListener"
,
"sourceType"
:
"org.springframework.boot.context.logging.LoggingApplicationListener"
,
"deprecation"
:
{
"deprecation"
:
{
"replacement"
:
"logging.file.name"
"replacement"
:
"logging.file.name"
,
"level"
:
"error"
}
}
},
},
{
{
...
@@ -146,7 +147,8 @@
...
@@ -146,7 +147,8 @@
"description"
:
"Location of the log file. For instance, `/var/log`."
,
"description"
:
"Location of the log file. For instance, `/var/log`."
,
"sourceType"
:
"org.springframework.boot.context.logging.LoggingApplicationListener"
,
"sourceType"
:
"org.springframework.boot.context.logging.LoggingApplicationListener"
,
"deprecation"
:
{
"deprecation"
:
{
"replacement"
:
"logging.file.path"
"replacement"
:
"logging.file.path"
,
"level"
:
"error"
}
}
},
},
{
{
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerIntegrationTests.java
View file @
7031a3b1
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -59,7 +59,7 @@ class LoggingApplicationListenerIntegrationTests {
...
@@ -59,7 +59,7 @@ class LoggingApplicationListenerIntegrationTests {
void
logFileRegisteredInTheContextWhenApplicable
(
@TempDir
File
tempDir
)
throws
Exception
{
void
logFileRegisteredInTheContextWhenApplicable
(
@TempDir
File
tempDir
)
throws
Exception
{
String
logFile
=
new
File
(
tempDir
,
"test.log"
).
getAbsolutePath
();
String
logFile
=
new
File
(
tempDir
,
"test.log"
).
getAbsolutePath
();
try
(
ConfigurableApplicationContext
context
=
new
SpringApplicationBuilder
(
SampleService
.
class
)
try
(
ConfigurableApplicationContext
context
=
new
SpringApplicationBuilder
(
SampleService
.
class
)
.
web
(
WebApplicationType
.
NONE
).
properties
(
"logging.file="
+
logFile
).
run
())
{
.
web
(
WebApplicationType
.
NONE
).
properties
(
"logging.file
.name
="
+
logFile
).
run
())
{
SampleService
service
=
context
.
getBean
(
SampleService
.
class
);
SampleService
service
=
context
.
getBean
(
SampleService
.
class
);
assertThat
(
service
.
logFile
).
isNotNull
();
assertThat
(
service
.
logFile
).
isNotNull
();
assertThat
(
service
.
logFile
.
toString
()).
isEqualTo
(
logFile
);
assertThat
(
service
.
logFile
.
toString
()).
isEqualTo
(
logFile
);
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java
View file @
7031a3b1
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -212,19 +212,6 @@ class LoggingApplicationListenerTests {
...
@@ -212,19 +212,6 @@ class LoggingApplicationListenerTests {
assertThat
(
output
).
startsWith
(
this
.
logFile
.
getAbsolutePath
());
assertThat
(
output
).
startsWith
(
this
.
logFile
.
getAbsolutePath
());
}
}
@Test
@Deprecated
void
addLogFilePropertyWithDeprecatedProperty
()
{
addPropertiesToEnvironment
(
this
.
context
,
"logging.config=classpath:logback-nondefault.xml"
,
"logging.file="
+
this
.
logFile
);
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
context
.
getClassLoader
());
Log
logger
=
LogFactory
.
getLog
(
LoggingApplicationListenerTests
.
class
);
String
existingOutput
=
this
.
output
.
toString
();
logger
.
info
(
"Hello world"
);
String
output
=
this
.
output
.
toString
().
substring
(
existingOutput
.
length
()).
trim
();
assertThat
(
output
).
startsWith
(
this
.
logFile
.
getAbsolutePath
());
}
@Test
@Test
void
addLogFilePropertyWithDefault
()
{
void
addLogFilePropertyWithDefault
()
{
assertThat
(
this
.
logFile
).
doesNotExist
();
assertThat
(
this
.
logFile
).
doesNotExist
();
...
@@ -235,16 +222,6 @@ class LoggingApplicationListenerTests {
...
@@ -235,16 +222,6 @@ class LoggingApplicationListenerTests {
assertThat
(
this
.
logFile
).
isFile
();
assertThat
(
this
.
logFile
).
isFile
();
}
}
@Test
@Deprecated
void
addLogFilePropertyWithDefaultAndDeprecatedProperty
()
{
addPropertiesToEnvironment
(
this
.
context
,
"logging.file="
+
this
.
logFile
);
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
context
.
getClassLoader
());
Log
logger
=
LogFactory
.
getLog
(
LoggingApplicationListenerTests
.
class
);
logger
.
info
(
"Hello world"
);
assertThat
(
this
.
logFile
).
isFile
();
}
@Test
@Test
void
addLogPathProperty
()
{
void
addLogPathProperty
()
{
addPropertiesToEnvironment
(
this
.
context
,
"logging.config=classpath:logback-nondefault.xml"
,
addPropertiesToEnvironment
(
this
.
context
,
"logging.config=classpath:logback-nondefault.xml"
,
...
@@ -257,18 +234,6 @@ class LoggingApplicationListenerTests {
...
@@ -257,18 +234,6 @@ class LoggingApplicationListenerTests {
assertThat
(
output
).
startsWith
(
new
File
(
this
.
tempDir
.
toFile
(),
"spring.log"
).
getAbsolutePath
());
assertThat
(
output
).
startsWith
(
new
File
(
this
.
tempDir
.
toFile
(),
"spring.log"
).
getAbsolutePath
());
}
}
@Test
void
addLogPathPropertyWithDeprecatedProperty
()
{
addPropertiesToEnvironment
(
this
.
context
,
"logging.config=classpath:logback-nondefault.xml"
,
"logging.path="
+
this
.
tempDir
);
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
context
.
getClassLoader
());
Log
logger
=
LogFactory
.
getLog
(
LoggingApplicationListenerTests
.
class
);
String
existingOutput
=
this
.
output
.
toString
();
logger
.
info
(
"Hello world"
);
String
output
=
this
.
output
.
toString
().
substring
(
existingOutput
.
length
()).
trim
();
assertThat
(
output
).
startsWith
(
new
File
(
this
.
tempDir
.
toFile
(),
"spring.log"
).
getAbsolutePath
());
}
@Test
@Test
void
parseDebugArg
()
{
void
parseDebugArg
()
{
addPropertiesToEnvironment
(
this
.
context
,
"debug"
);
addPropertiesToEnvironment
(
this
.
context
,
"debug"
);
...
@@ -495,15 +460,6 @@ class LoggingApplicationListenerTests {
...
@@ -495,15 +460,6 @@ class LoggingApplicationListenerTests {
assertThat
(
System
.
getProperty
(
LoggingSystemProperties
.
PID_KEY
)).
isNotNull
();
assertThat
(
System
.
getProperty
(
LoggingSystemProperties
.
PID_KEY
)).
isNotNull
();
}
}
@Test
@Deprecated
void
systemPropertiesAreSetForLoggingConfigurationWithDeprecatedProperties
()
{
addPropertiesToEnvironment
(
this
.
context
,
"logging.file="
+
this
.
logFile
,
"logging.path=path"
);
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
context
.
getClassLoader
());
assertThat
(
System
.
getProperty
(
LoggingSystemProperties
.
LOG_FILE
)).
isEqualTo
(
this
.
logFile
.
getAbsolutePath
());
assertThat
(
System
.
getProperty
(
LoggingSystemProperties
.
LOG_PATH
)).
isEqualTo
(
"path"
);
}
@Test
@Test
void
environmentPropertiesIgnoreUnresolvablePlaceholders
()
{
void
environmentPropertiesIgnoreUnresolvablePlaceholders
()
{
// gh-7719
// gh-7719
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/LogFileTests.java
View file @
7031a3b1
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -52,13 +52,6 @@ class LogFileTests {
...
@@ -52,13 +52,6 @@ class LogFileTests {
testLoggingFile
(
resolver
);
testLoggingFile
(
resolver
);
}
}
@Test
@Deprecated
void
loggingFileWithDeprecatedProperties
()
{
PropertyResolver
resolver
=
getPropertyResolver
(
Collections
.
singletonMap
(
"logging.file"
,
"log.file"
));
testLoggingFile
(
resolver
);
}
private
void
testLoggingFile
(
PropertyResolver
resolver
)
{
private
void
testLoggingFile
(
PropertyResolver
resolver
)
{
LogFile
logFile
=
LogFile
.
get
(
resolver
);
LogFile
logFile
=
LogFile
.
get
(
resolver
);
Properties
properties
=
new
Properties
();
Properties
properties
=
new
Properties
();
...
@@ -74,13 +67,6 @@ class LogFileTests {
...
@@ -74,13 +67,6 @@ class LogFileTests {
testLoggingPath
(
resolver
);
testLoggingPath
(
resolver
);
}
}
@Test
@Deprecated
void
loggingPathWithDeprecatedProperties
()
{
PropertyResolver
resolver
=
getPropertyResolver
(
Collections
.
singletonMap
(
"logging.path"
,
"logpath"
));
testLoggingPath
(
resolver
);
}
private
void
testLoggingPath
(
PropertyResolver
resolver
)
{
private
void
testLoggingPath
(
PropertyResolver
resolver
)
{
LogFile
logFile
=
LogFile
.
get
(
resolver
);
LogFile
logFile
=
LogFile
.
get
(
resolver
);
Properties
properties
=
new
Properties
();
Properties
properties
=
new
Properties
();
...
@@ -100,16 +86,6 @@ class LogFileTests {
...
@@ -100,16 +86,6 @@ class LogFileTests {
testLoggingFileAndPath
(
resolver
);
testLoggingFileAndPath
(
resolver
);
}
}
@Test
@Deprecated
void
loggingFileAndPathWithDeprecatedProperties
()
{
Map
<
String
,
Object
>
properties
=
new
LinkedHashMap
<>();
properties
.
put
(
"logging.file"
,
"log.file"
);
properties
.
put
(
"logging.path"
,
"logpath"
);
PropertyResolver
resolver
=
getPropertyResolver
(
properties
);
testLoggingFileAndPath
(
resolver
);
}
private
void
testLoggingFileAndPath
(
PropertyResolver
resolver
)
{
private
void
testLoggingFileAndPath
(
PropertyResolver
resolver
)
{
LogFile
logFile
=
LogFile
.
get
(
resolver
);
LogFile
logFile
=
LogFile
.
get
(
resolver
);
Properties
properties
=
new
Properties
();
Properties
properties
=
new
Properties
();
...
...
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