You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2022/01/16 15:31:33 UTC
[logging-log4j2] branch release-2.x updated: Add and @Ignore test.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/release-2.x by this push:
new 63a5da8 Add and @Ignore test.
63a5da8 is described below
commit 63a5da8ffe4c21b05d9b1125c846840e500779f4
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jan 16 10:29:02 2022 -0500
Add and @Ignore test.
Simpler to add @Ignore'd test than to swap git stashes back and forth.
---
.../log4j/config/XmlRollingWithPropertiesTest.java | 59 ++++++++++++++++++++++
.../test/resources/log4j1-rolling-properties.xml | 31 ++++++++++++
2 files changed, 90 insertions(+)
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlRollingWithPropertiesTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlRollingWithPropertiesTest.java
new file mode 100644
index 0000000..858ba68
--- /dev/null
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlRollingWithPropertiesTest.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.log4j.config;
+
+import static org.junit.Assert.assertTrue;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.logging.log4j.test.SystemPropertyTestRule;
+import org.junit.ClassRule;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TestRule;
+
+/**
+ * Test configuration from Properties.
+ */
+@Ignore
+public class XmlRollingWithPropertiesTest {
+
+ private static final String TEST_DIR = "target/" + XmlRollingWithPropertiesTest.class.getSimpleName();
+
+ @ClassRule
+ public static TestRule SP_RULE = RuleChain.emptyRuleChain()
+ //@formatter:off
+ .around(SystemPropertyTestRule.create("test.directory", TEST_DIR))
+ .around(SystemPropertyTestRule.create("log4j.configuration", "target/test-classes/log4j1-rolling-properties.xml"));
+ //@formatter:on
+
+ @Test
+ public void testProperties() throws Exception {
+ // ${test.directory}/logs/etl.log
+ Logger logger = LogManager.getLogger("test");
+ logger.debug("This is a test of the root logger");
+ Path path = Paths.get(TEST_DIR, "logs/etl.log");
+ assertTrue("Log file was not created", Files.exists(path));
+ assertTrue("Log file is empty", Files.size(path) > 0);
+ }
+
+}
diff --git a/log4j-1.2-api/src/test/resources/log4j1-rolling-properties.xml b/log4j-1.2-api/src/test/resources/log4j1-rolling-properties.xml
new file mode 100644
index 0000000..c138a25
--- /dev/null
+++ b/log4j-1.2-api/src/test/resources/log4j1-rolling-properties.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- See https://issues.apache.org/jira/browse/LOG4J2-3328 -->
+<log4j:configuration>
+ <appender name="DAILY" class="org.apache.log4j.RollingFileAppender">
+ <param name="File" value="${sys:test.directory}/logs/etl.log" />
+ <param name="DatePattern" value="'.'yyyy-MM-dd" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="GATEWAY: %p %d [%t] %c{1}.%M(%L) | %m%n" />
+ </layout>
+ </appender>
+ <root>
+ <priority value="OFF" />
+ <appender-ref ref="DAILY" />
+ </root>
+</log4j:configuration>