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
0963218b
Commit
0963218b
authored
Sep 21, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.2.x' into 2.3.x
parents
13e08a43
0edf7cb9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
7 deletions
+28
-7
Log4j2FileXmlTests.java
...ringframework/boot/logging/log4j2/Log4j2FileXmlTests.java
+12
-5
Log4j2XmlTests.java
...g/springframework/boot/logging/log4j2/Log4j2XmlTests.java
+16
-2
No files found.
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4j2FileXmlTests.java
View file @
0963218b
...
...
@@ -36,13 +36,20 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
class
Log4j2FileXmlTests
extends
Log4j2XmlTests
{
@TempDir
File
temp
;
@Override
@BeforeEach
void
configureLogFile
(
@TempDir
File
temp
)
{
System
.
setProperty
(
LoggingSystemProperties
.
LOG_FILE
,
new
File
(
temp
,
"test.log"
).
getAbsolutePath
());
void
prepareConfiguration
()
{
System
.
setProperty
(
LoggingSystemProperties
.
LOG_FILE
,
new
File
(
this
.
temp
,
"test.log"
).
getAbsolutePath
());
super
.
prepareConfiguration
();
}
@Override
@AfterEach
void
clearLogFile
()
{
void
stopConfiguration
()
{
super
.
stopConfiguration
();
System
.
clearProperty
(
LoggingSystemProperties
.
LOG_FILE
);
}
...
...
@@ -75,8 +82,8 @@ class Log4j2FileXmlTests extends Log4j2XmlTests {
@Test
void
whenLogDateformatPatternIsSetThenFileAppenderUsesIt
()
{
withSystemProperty
(
LoggingSystemProperties
.
LOG_DATEFORMAT_PATTERN
,
"
custom
"
,
()
->
assertThat
(
fileAppenderPattern
()).
contains
(
"
custom
"
));
withSystemProperty
(
LoggingSystemProperties
.
LOG_DATEFORMAT_PATTERN
,
"
dd-MM-yyyy
"
,
()
->
assertThat
(
fileAppenderPattern
()).
contains
(
"
dd-MM-yyyy
"
));
}
@Override
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4j2XmlTests.java
View file @
0963218b
...
...
@@ -24,6 +24,8 @@ import org.apache.logging.log4j.core.config.Configuration;
import
org.apache.logging.log4j.core.config.ConfigurationFactory
;
import
org.apache.logging.log4j.core.config.ConfigurationSource
;
import
org.apache.logging.log4j.core.layout.PatternLayout
;
import
org.junit.jupiter.api.AfterEach
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.logging.LoggingSystemProperties
;
...
...
@@ -37,6 +39,18 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
class
Log4j2XmlTests
{
private
Configuration
configuration
;
@BeforeEach
void
prepareConfiguration
()
{
this
.
configuration
=
initializeConfiguration
();
}
@AfterEach
void
stopConfiguration
()
{
this
.
configuration
.
stop
();
}
@Test
void
whenLogExceptionConversionWordIsNotConfiguredThenConsoleUsesDefault
()
{
assertThat
(
consolePattern
()).
contains
(
"%xwEx"
);
...
...
@@ -66,8 +80,8 @@ class Log4j2XmlTests {
@Test
void
whenLogDateformatPatternIsSetThenConsoleUsesIt
()
{
withSystemProperty
(
LoggingSystemProperties
.
LOG_DATEFORMAT_PATTERN
,
"
custom
"
,
()
->
assertThat
(
consolePattern
()).
contains
(
"
custom
"
));
withSystemProperty
(
LoggingSystemProperties
.
LOG_DATEFORMAT_PATTERN
,
"
dd-MM-yyyy
"
,
()
->
assertThat
(
consolePattern
()).
contains
(
"
dd-MM-yyyy
"
));
}
protected
void
withSystemProperty
(
String
name
,
String
value
,
Runnable
action
)
{
...
...
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