Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
xiaofang li
Logging Log4j2
Commits
adf03f41
Commit
adf03f41
authored
7 years ago
by
Ralph Goers
Browse files
Options
Download
Email Patches
Plain Diff
Hopefully fix unit test
parent
1f15422a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteWithReconfigureTest.java
+12
-5
...olling/RollingAppenderDirectWriteWithReconfigureTest.java
log4j-core/src/test/resources/log4j-rolling-direct-reconfigure.xml
+2
-2
...e/src/test/resources/log4j-rolling-direct-reconfigure.xml
with
14 additions
and
7 deletions
+14
-7
log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteWithReconfigureTest.java
+
12
-
5
View file @
adf03f41
...
...
@@ -20,6 +20,7 @@ import java.net.URI;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.core.LoggerContext
;
import
org.apache.logging.log4j.core.config.Configuration
;
import
org.apache.logging.log4j.junit.LoggerContextRule
;
import
org.junit.Before
;
import
org.junit.Rule
;
...
...
@@ -35,6 +36,8 @@ public class RollingAppenderDirectWriteWithReconfigureTest {
private
static
final
String
DIR
=
"target/rolling-direct-reconfigure"
;
private
static
final
int
MAX_TRIES
=
10
;
public
static
LoggerContextRule
loggerContextRule
=
LoggerContextRule
.
createShutdownTimeoutLoggerContextRule
(
CONFIG
);
...
...
@@ -54,14 +57,18 @@ public class RollingAppenderDirectWriteWithReconfigureTest {
@SuppressWarnings
(
"resource"
)
// managed by the rule.
final
LoggerContext
context
=
loggerContextRule
.
getLoggerContext
();
Configuration
config
=
context
.
getConfiguration
();
context
.
setConfigLocation
(
new
URI
(
CONFIG
));
context
.
reconfigure
();
Thread
.
sleep
(
2000
);
logger
.
debug
(
"After reconfigure"
);
logger
.
debug
(
"Force a rollover"
);
final
File
dir
=
new
File
(
DIR
);
for
(
int
i
=
0
;
i
<
MAX_TRIES
;
++
i
)
{
Thread
.
sleep
(
200
);
if
(
config
!=
context
.
getConfiguration
())
{
break
;
}
}
assertTrue
(
"Directory not created"
,
dir
.
exists
()
&&
dir
.
listFiles
().
length
>
0
);
final
File
[]
files
=
dir
.
listFiles
();
assertNotNull
(
files
);
...
...
This diff is collapsed.
Click to expand it.
log4j-core/src/test/resources/log4j-rolling-direct-reconfigure.xml
+
2
-
2
View file @
adf03f41
...
...
@@ -27,11 +27,11 @@
<Console
name=
"STDOUT"
>
<PatternLayout
pattern=
"%m%n"
/>
</Console>
<RollingFile
name=
"RollingFile"
filePattern=
"${LOG_DIR}/test1-
%d{
MM-dd-yy-HH-mm-ss}.log"
>
<RollingFile
name=
"RollingFile"
filePattern=
"${LOG_DIR}/test1-
$${date:
MM-dd-yy-HH-mm-ss
-SSS
}.log"
>
<PatternLayout>
<Pattern>
%d %p %C{1.} [%t] %m%n
</Pattern>
</PatternLayout>
<
Cron
TriggeringPolicy
s
chedule=
"0/1 * * * * ?
"
/>
<
SizeBased
TriggeringPolicy
s
ize=
"25
"
/>
</RollingFile>
</Appenders>
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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
Menu
Projects
Groups
Snippets
Help