org.apache.logging.log4j.core.lookup
Class Interpolator

java.lang.Object
  extended by org.apache.logging.log4j.core.lookup.AbstractLookup
      extended by org.apache.logging.log4j.core.lookup.Interpolator
All Implemented Interfaces:
StrLookup

public class Interpolator
extends AbstractLookup

Proxies all the other StrLookups.


Field Summary
 
Fields inherited from interface org.apache.logging.log4j.core.lookup.StrLookup
CATEGORY
 
Constructor Summary
Interpolator()
          Create the default Interpolator using only Lookups that work without an event.
Interpolator(Map<String,String> properties)
          Creates the Interpolator using only Lookups that work without an event and initial properties.
Interpolator(StrLookup defaultLookup)
           
Interpolator(StrLookup defaultLookup, List<String> pluginPackages)
          Constructs an Interpolator using a given StrLookup and a list of packages to find Lookup plugins in.
 
Method Summary
 String lookup(LogEvent event, String var)
          Resolves the specified variable.
 String toString()
           
 
Methods inherited from class org.apache.logging.log4j.core.lookup.AbstractLookup
lookup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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 using only Lookups that work without an event.


Interpolator

public Interpolator(Map<String,String> properties)
Creates the Interpolator using only Lookups that work without an event and initial properties.

Method Detail

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.

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 String toString()
Overrides:
toString in class Object


Copyright © 1999-2014 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.