Class DefaultMergeStrategy

java.lang.Object
org.apache.logging.log4j.core.config.composite.DefaultMergeStrategy
All Implemented Interfaces:
MergeStrategy

public class DefaultMergeStrategy extends Object implements MergeStrategy
The default merge strategy for composite configurations.

The default merge strategy performs the merge according to the following rules:

  1. Aggregates the global configuration attributes with those in later configurations replacing those in previous configurations with the exception that the highest status level and the lowest monitorInterval greater than 0 will be used.
  2. Properties from all configurations are aggregated. Duplicate properties replace those in previous configurations.
  3. Filters are aggregated under a CompositeFilter if more than one Filter is defined. Since Filters are not named duplicates may be present.
  4. Scripts and ScriptFile references are aggregated. Duplicate definitions replace those in previous configurations.
  5. Appenders are aggregated. Appenders with the same name are replaced by those in later configurations, including all of the Appender's subcomponents.
  6. Loggers are all aggregated. Logger attributes are individually merged with duplicates being replaced by those in later configurations. Appender references on a Logger are aggregated with duplicates being replaced by those in later configurations. Filters on a Logger are aggregated under a CompositeFilter if more than one Filter is defined. Since Filters are not named duplicates may be present. Filters under Appender references included or discarded depending on whether their parent Appender reference is kept or discarded.
  • Constructor Details

    • DefaultMergeStrategy

      public DefaultMergeStrategy()
  • Method Details

    • mergeRootProperties

      public void mergeRootProperties(Node rootNode, AbstractConfiguration configuration)
      Merge the root properties.
      Specified by:
      mergeRootProperties in interface MergeStrategy
      Parameters:
      rootNode - The composite root node.
      configuration - The configuration to merge.
    • mergConfigurations

      public void mergConfigurations(Node target, Node source, PluginManager pluginManager)
      Merge the source Configuration into the target Configuration.
      Specified by:
      mergConfigurations in interface MergeStrategy
      Parameters:
      target - The target node to merge into.
      source - The source node.
      pluginManager - The PluginManager.