public void mergeRootProperties()

in log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/DefaultMergeStrategy.java [75:118]


    public void mergeRootProperties(final Node rootNode, final AbstractConfiguration configuration) {
        for (final Map.Entry<String, String> attribute :
                configuration.getRootNode().getAttributes().entrySet()) {
            boolean isFound = false;
            for (final Map.Entry<String, String> targetAttribute :
                    rootNode.getAttributes().entrySet()) {
                if (targetAttribute.getKey().equalsIgnoreCase(attribute.getKey())) {
                    if (attribute.getKey().equalsIgnoreCase(STATUS)) {
                        final Level targetLevel = Level.getLevel(toRootUpperCase(targetAttribute.getValue()));
                        final Level sourceLevel = Level.getLevel(toRootUpperCase(attribute.getValue()));
                        if (targetLevel != null && sourceLevel != null) {
                            if (sourceLevel.isLessSpecificThan(targetLevel)) {
                                targetAttribute.setValue(attribute.getValue());
                            }
                        } else if (sourceLevel != null) {
                            targetAttribute.setValue(attribute.getValue());
                        }
                    } else if (attribute.getKey().equalsIgnoreCase("monitorInterval")) {
                        final int sourceInterval = Integers.parseInt(attribute.getValue());
                        final int targetInterval = Integers.parseInt(targetAttribute.getValue());
                        if (targetInterval == 0 || sourceInterval < targetInterval) {
                            targetAttribute.setValue(attribute.getValue());
                        }
                    } else if (attribute.getKey().equalsIgnoreCase("packages")) {
                        final String sourcePackages = attribute.getValue();
                        final String targetPackages = targetAttribute.getValue();
                        if (sourcePackages != null) {
                            if (targetPackages != null) {
                                targetAttribute.setValue(targetPackages + "," + sourcePackages);
                            } else {
                                targetAttribute.setValue(sourcePackages);
                            }
                        }
                    } else {
                        targetAttribute.setValue(attribute.getValue());
                    }
                    isFound = true;
                }
            }
            if (!isFound) {
                rootNode.getAttributes().put(attribute.getKey(), attribute.getValue());
            }
        }
    }