Skip to content

Commit b642f1a

Browse files
committed
Split off YAML configuration into its own module
This splits `YamlConfiguration` into its own module and removes `jackson-dataformat-yaml` from `log4j-core`'s optional dependencies.
1 parent 01b6e2d commit b642f1a

File tree

28 files changed

+337
-274
lines changed

28 files changed

+337
-274
lines changed

log4j-config-yaml/pom.xml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one or more
4+
~ contributor license agreements. See the NOTICE file distributed with
5+
~ this work for additional information regarding copyright ownership.
6+
~ The ASF licenses this file to you under the Apache License, Version 2.0
7+
~ (the "License"); you may not use this file except in compliance with
8+
~ the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
-->
18+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
19+
<modelVersion>4.0.0</modelVersion>
20+
<parent>
21+
<groupId>org.apache.logging.log4j</groupId>
22+
<artifactId>log4j</artifactId>
23+
<version>${revision}</version>
24+
<relativePath>../log4j-parent</relativePath>
25+
</parent>
26+
27+
<artifactId>log4j-config-yaml</artifactId>
28+
29+
<dependencies>
30+
31+
<dependency>
32+
<groupId>org.apache.logging.log4j</groupId>
33+
<artifactId>log4j-core</artifactId>
34+
</dependency>
35+
36+
<dependency>
37+
<groupId>com.fasterxml.jackson.dataformat</groupId>
38+
<artifactId>jackson-dataformat-yaml</artifactId>
39+
</dependency>
40+
41+
<dependency>
42+
<groupId>org.apache.logging.log4j</groupId>
43+
<artifactId>log4j-core-test</artifactId>
44+
<scope>test</scope>
45+
</dependency>
46+
47+
</dependencies>
48+
49+
<build>
50+
<plugins>
51+
<plugin>
52+
<groupId>org.apache.maven.plugins</groupId>
53+
<artifactId>maven-compiler-plugin</artifactId>
54+
<configuration>
55+
<annotationProcessorPaths combine.children="append">
56+
<path>
57+
<groupId>org.apache.logging.log4j</groupId>
58+
<artifactId>log4j-plugin-processor</artifactId>
59+
<version>${project.version}</version>
60+
</path>
61+
</annotationProcessorPaths>
62+
</configuration>
63+
</plugin>
64+
</plugins>
65+
</build>
66+
</project>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
package org.apache.logging.log4j.core.config;
17+
package org.apache.logging.log4j.config.yaml;
1818

1919
import static org.junit.jupiter.api.Assertions.assertEquals;
2020
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -24,6 +24,7 @@
2424
import org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy;
2525
import org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy;
2626
import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
27+
import org.apache.logging.log4j.core.config.Configuration;
2728
import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
2829
import org.junit.jupiter.api.Disabled;
2930
import org.junit.jupiter.api.Tag;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to you under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.logging.log4j.config.yaml;
18+
19+
import java.io.IOException;
20+
import java.nio.file.Path;
21+
import org.apache.logging.log4j.core.LoggerContext;
22+
import org.apache.logging.log4j.core.config.AbstractConfigurationFactoryTest;
23+
import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
24+
import org.apache.logging.log4j.test.junit.TempLoggingDir;
25+
import org.junit.jupiter.api.Test;
26+
27+
class YamlConfigurationFactoryTest extends AbstractConfigurationFactoryTest {
28+
29+
@TempLoggingDir
30+
private static Path loggingPath;
31+
32+
@Test
33+
@LoggerContextSource("YamlConfigurationFactoryTest.yaml")
34+
void yamlConfiguration(final LoggerContext context) throws IOException {
35+
checkConfiguration(context);
36+
final Path logFile = loggingPath.resolve("test-yaml.log");
37+
checkFileLogger(context, logFile);
38+
}
39+
}

0 commit comments

Comments
 (0)