Class Interpolator

All Implemented Interfaces:
ConfigurationAware, LoggerContextAware, StrLookup

public class Interpolator extends AbstractConfigurationAwareLookup implements LoggerContextAware
Proxies all the other StrLookups.
  • Field Details

  • Constructor Details

    • Interpolator

      public Interpolator(StrLookup defaultLookup)
    • Interpolator

      public Interpolator(StrLookup defaultLookup, List<String> pluginPackages)
      Constructs an Interpolator using a given StrLookup and a list of packages to find Lookup plugins in.
      Parameters:
      defaultLookup - the default StrLookup to use as a fallback
      pluginPackages - a list of packages to scan for Lookup plugins
      Since:
      2.1
    • Interpolator

      public Interpolator()
      Create the default Interpolator.
    • Interpolator

      public Interpolator(Map<String,String> properties)
      Creates the default Interpolator with the provided properties.
  • Method Details

    • getDefaultLookup

      public StrLookup getDefaultLookup()
    • getStrLookupMap

      public Map<String,StrLookup> getStrLookupMap()
    • lookup

      public String lookup(LogEvent event, String var)
      Resolves the specified variable. This implementation will try to extract a variable prefix from the given variable name (the first colon (':') is used as prefix separator). It then passes the name of the variable with the prefix stripped to the lookup object registered for this prefix. If no prefix can be found or if the associated lookup object cannot resolve this variable, the default lookup object will be used.
      Specified by:
      lookup in interface StrLookup
      Parameters:
      event - The current LogEvent or null.
      var - the name of the variable whose value is to be looked up
      Returns:
      the value of this variable or null if it cannot be resolved
    • evaluate

      public LookupResult evaluate(LogEvent event, String var)
      Resolves the specified variable. This implementation will try to extract a variable prefix from the given variable name (the first colon (':') is used as prefix separator). It then passes the name of the variable with the prefix stripped to the lookup object registered for this prefix. If no prefix can be found or if the associated lookup object cannot resolve this variable, the default lookup object will be used.
      Specified by:
      evaluate in interface StrLookup
      Parameters:
      event - The current LogEvent or null.
      var - the name of the variable whose value is to be looked up
      Returns:
      the value of this variable or null if it cannot be resolved
    • setConfiguration

      public void setConfiguration(Configuration configuration)
      Description copied from interface: ConfigurationAware
      Injects the current Configuration into this object.
      Specified by:
      setConfiguration in interface ConfigurationAware
      Overrides:
      setConfiguration in class AbstractConfigurationAwareLookup
      Parameters:
      configuration - the current Configuration
    • setLoggerContext

      public void setLoggerContext(LoggerContext loggerContext)
      Description copied from interface: LoggerContextAware
      Injects the current LoggerContext into this object.
      Specified by:
      setLoggerContext in interface LoggerContextAware
      Parameters:
      loggerContext - the current LoggerContext
    • toString

      public String toString()
      Overrides:
      toString in class Object