JWT007 opened a new issue, #3173: URL: https://github.com/apache/logging-log4j2/issues/3173
DefaultMergeStrategy (Log4j 2.24.1) In `DefaultMergeStrategy#updateFilterNode` I *think* there is a problem when merging two configurations with filters and the target does not *yet* contain a `CompositeFilter`. (in the code below this is the `else`case). ``` private void updateFilterNode( final Node target, final Node targetChildNode, final Node sourceChildNode, final PluginManager pluginManager) { if (CompositeFilter.class.isAssignableFrom(targetChildNode.getType().getPluginClass())) { final Node node = new Node(targetChildNode, sourceChildNode.getName(), sourceChildNode.getType()); node.getChildren().addAll(sourceChildNode.getChildren()); node.getAttributes().putAll(sourceChildNode.getAttributes()); targetChildNode.getChildren().add(node); } else { final PluginType pluginType = pluginManager.getPluginType(FILTERS); final Node filtersNode = new Node(targetChildNode, FILTERS, pluginType); final Node node = new Node(filtersNode, sourceChildNode.getName(), sourceChildNode.getType()); node.getAttributes().putAll(sourceChildNode.getAttributes()); final List<Node> children = filtersNode.getChildren(); children.add(targetChildNode); children.add(node); final List<Node> nodes = target.getChildren(); nodes.remove(targetChildNode); nodes.add(filtersNode); } } ``` If I am not mistaken, there is a step missing to add the children of the 'sourceChildNode' to the new `node`. I think it should be (see line commented with "`<==== ADDED`"). ``` else { final PluginType pluginType = pluginManager.getPluginType(FILTERS); final Node filtersNode = new Node(targetChildNode, FILTERS, pluginType); final Node node = new Node(filtersNode, sourceChildNode.getName(), sourceChildNode.getType()); node.getChildren().addAll(sourceChildeNode.getChildren()); // <==== ADDED node.getAttributes().putAll(sourceChildNode.getAttributes()); final List<Node> children = filtersNode.getChildren(); children.add(targetChildNode); children.add(node); final List<Node> nodes = target.getChildren(); nodes.remove(targetChildNode); nodes.add(filtersNode); } } ``` For example if merging a secondary configuration (source) containing the following filter to a base configuration (target) when the target contains a filter (but *not* a `CompositeFilter`): ``` <Configuration> <DynamicThresholdFilter key="loginId" defaultThreshold="ERROR"> <KeyValuePair key="alice" value="DEBUG"/> <KeyValuePair key="bob" value="INFO"/> </DynamicThresholdFilter> </Configuration> ``` ::: I *believe* all the `KeyValuePair` children would be dropped during merge with the current code. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org