This is an automated email from the ASF dual-hosted git repository.
pkarwasz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/master by this push:
new bee1166479 Fix location requirements in `RewriteAppender`
bee1166479 is described below
commit bee1166479a581046e54c94745acd37a324eb556
Author: Piotr P. Karwasz <[email protected]>
AuthorDate: Mon Feb 13 21:15:18 2023 +0100
Fix location requirements in `RewriteAppender`
`RewriteAppender` did not correctly compute if it requires location
information. This closes #1274.
---
.../core/appender/rewrite/RewriteAppender.java | 18 +++++++++++---
.../1274_fix_RewriteAppender_requiresLocation.xml | 28 ++++++++++++++++++++++
2 files changed, 43 insertions(+), 3 deletions(-)
diff --git
a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppender.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppender.java
index 50923288ea..77dc527ebf 100644
---
a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppender.java
+++
b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppender.java
@@ -16,6 +16,9 @@
*/
package org.apache.logging.log4j.core.appender.rewrite;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.LogEvent;
@@ -32,9 +35,6 @@ import org.apache.logging.log4j.plugins.PluginElement;
import org.apache.logging.log4j.plugins.PluginFactory;
import org.apache.logging.log4j.plugins.validation.constraints.Required;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
/**
* This Appender allows the logging event to be manipulated before it is
processed by other Appenders.
*/
@@ -107,4 +107,16 @@ public final class RewriteAppender extends
AbstractAppender {
@PluginElement final Filter filter) {
return new RewriteAppender(name, filter, ignoreExceptions,
appenderRefs, rewritePolicy, config, Property.EMPTY_ARRAY);
}
+
+ @Override
+ public boolean requiresLocation() {
+ for (final AppenderControl control : appenders.values()) {
+ final Appender appender = control.getAppender();
+ if (appender.requiresLocation()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
}
diff --git a/src/changelog/.2.x.x/1274_fix_RewriteAppender_requiresLocation.xml
b/src/changelog/.2.x.x/1274_fix_RewriteAppender_requiresLocation.xml
new file mode 100644
index 0000000000..addc434e93
--- /dev/null
+++ b/src/changelog/.2.x.x/1274_fix_RewriteAppender_requiresLocation.xml
@@ -0,0 +1,28 @@
+<?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.
+-->
+<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://logging.apache.org/log4j/changelog"
+ xsi:schemaLocation="http://logging.apache.org/log4j/changelog
https://logging.apache.org/log4j/changelog-0.1.0.xsd"
+ type="fixed">
+ <issue id="1274" link="https://github.com/apache/logging-log4j2/pull/1274"/>
+ <author id="amirhadadi"/>
+ <author id="pkarwasz"/>
+ <description format="asciidoc">
+ Fix detection of location requirements in `RewriteAppender`.
+ </description>
+</entry>