Class Interpolator

    • Field Detail

      • PREFIX_SEPARATOR

        public static final char PREFIX_SEPARATOR
        Constant for the prefix separator.
        See Also:
        Constant Field Values
      • LOOKUP_KEY_DOCKER

        private static final java.lang.String LOOKUP_KEY_DOCKER
        See Also:
        Constant Field Values
      • LOOKUP_KEY_KUBERNETES

        private static final java.lang.String LOOKUP_KEY_KUBERNETES
        See Also:
        Constant Field Values
      • LOOKUP_KEY_SPRING

        private static final java.lang.String LOOKUP_KEY_SPRING
        See Also:
        Constant Field Values
      • LOOKUP_KEY_JVMRUNARGS

        private static final java.lang.String LOOKUP_KEY_JVMRUNARGS
        See Also:
        Constant Field Values
      • LOGGER

        private static final Logger LOGGER
      • strLookupMap

        private final java.util.Map<java.lang.String,​StrLookup> strLookupMap
      • defaultLookup

        private final StrLookup defaultLookup
    • Constructor Detail

      • Interpolator

        public Interpolator​(StrLookup defaultLookup)
      • Interpolator

        public Interpolator​(StrLookup defaultLookup,
                            java.util.List<java.lang.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​(java.util.Map<java.lang.String,​java.lang.String> properties)
        Creates the default Interpolator with the provided properties.
    • Method Detail

      • getDefaultLookup

        public StrLookup getDefaultLookup()
      • getStrLookupMap

        public java.util.Map<java.lang.String,​StrLookup> getStrLookupMap()
      • handleError

        private void handleError​(java.lang.String lookupKey,
                                 java.lang.Throwable t)
      • lookup

        public java.lang.String lookup​(LogEvent event,
                                       java.lang.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.
        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,
                                     java.lang.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.
        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
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object