Skip to content

Commit 8e32278

Browse files
committed
added simple test for appender definitiob via file inclusion
Signed-off-by: ceki <ceki@qos.ch>
1 parent 834dbed commit 8e32278

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<included>
2+
3+
<appender name="LIST" class="ch.qos.logback.core.read.ListAppender"/>
4+
5+
</included>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!--
2+
~ Logback: the reliable, generic, fast and flexible logging framework.
3+
~ Copyright (C) 1999-2026, QOS.ch. All rights reserved.
4+
~
5+
~ This program and the accompanying materials are dual-licensed under
6+
~ either the terms of the Eclipse Public License v2.0 as published by
7+
~ the Eclipse Foundation
8+
~
9+
~ or (per the licensee's choosing)
10+
~
11+
~ under the terms of the GNU Lesser General Public License version 2.1
12+
~ as published by the Free Software Foundation.
13+
-->
14+
15+
<configuration>
16+
17+
<variable scope="system" name="JO_PREFIX" value="src/test/blackboxInput/joran"/>
18+
19+
<include file="${JO_PREFIX}/incl/includedListAppender.xml" />
20+
21+
<root level="TRACE">
22+
<appender-ref ref="LIST" />
23+
</root>
24+
25+
</configuration>

logback-classic-blackbox/src/test/java/ch/qos/logback/classic/blackbox/joran/BlackboxJoranConfiguratorTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,21 @@ void verifyJULLevel(String loggerName, Level expectedLevel) {
207207
}
208208
}
209209

210+
@Test
211+
public void includedAppender() throws JoranException {
212+
String configFileAsStr = BlackboxClassicTestConstants.JORAN_INPUT_PREFIX + "incl/topAppender.xml";
213+
configure(configFileAsStr);
214+
215+
ListAppender<?> listAppender = (ListAppender<?>) root.getAppender("LIST");
216+
assertNotNull(listAppender);
217+
218+
logger.debug("includedAppender");
219+
220+
assertEquals(1, listAppender.list.size());
221+
assertEquals(Level.TRACE, root.getLevel());
222+
223+
}
224+
210225
// See https://github.com/qos-ch/logback/issues/1001
211226
// See https://github.com/qos-ch/logback/issues/997
212227
@Test

logback-core/src/main/java/ch/qos/logback/core/model/processor/IncludeModelHandler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ public Model buildModelFromIncludedFile(ContextAwarePropertyContainer capc, URL
106106
return null;
107107
}
108108

109+
addInfo("Including configuration file [" + inputURL + "]");
110+
109111
SaxEventRecorder recorder = null;
110112

111113
try {

0 commit comments

Comments
 (0)