Class Interpolator
- java.lang.Object
-
- org.apache.logging.log4j.core.lookup.AbstractLookup
-
- org.apache.logging.log4j.core.lookup.AbstractConfigurationAwareLookup
-
- org.apache.logging.log4j.core.lookup.Interpolator
-
- All Implemented Interfaces:
ConfigurationAware,LoggerContextAware,StrLookup
public class Interpolator extends AbstractConfigurationAwareLookup implements LoggerContextAware
Proxies all the otherStrLookups.
-
-
Field Summary
Fields Modifier and Type Field Description protected WeakReference<LoggerContext>loggerContextstatic charPREFIX_SEPARATORConstant for the prefix separator.-
Fields inherited from class org.apache.logging.log4j.core.lookup.AbstractConfigurationAwareLookup
configuration
-
-
Constructor Summary
Constructors Constructor Description Interpolator()Create the default Interpolator.Interpolator(Map<String,String> properties)Creates the default Interpolator with the provided 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LookupResultevaluate(LogEvent event, String var)Resolves the specified variable.StrLookupgetDefaultLookup()Map<String,StrLookup>getStrLookupMap()Stringlookup(LogEvent event, String var)Resolves the specified variable.voidsetConfiguration(Configuration configuration)Injects the current Configuration into this object.voidsetLoggerContext(LoggerContext loggerContext)Injects the current LoggerContext into this object.StringtoString()-
Methods inherited from class org.apache.logging.log4j.core.lookup.AbstractLookup
evaluate, lookup
-
-
-
-
Field Detail
-
PREFIX_SEPARATOR
public static final char PREFIX_SEPARATOR
Constant for the prefix separator.- See Also:
- Constant Field Values
-
loggerContext
protected WeakReference<LoggerContext> loggerContext
-
-
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 fallbackpluginPackages- a list of packages to scan for Lookup plugins- Since:
- 2.1
-
Interpolator
public Interpolator()
Create the default Interpolator.
-
-
Method Detail
-
getDefaultLookup
public StrLookup getDefaultLookup()
-
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.
-
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.
-
setConfiguration
public void setConfiguration(Configuration configuration)
Description copied from interface:ConfigurationAwareInjects the current Configuration into this object.- Specified by:
setConfigurationin interfaceConfigurationAware- Overrides:
setConfigurationin classAbstractConfigurationAwareLookup- Parameters:
configuration- the current Configuration
-
setLoggerContext
public void setLoggerContext(LoggerContext loggerContext)
Description copied from interface:LoggerContextAwareInjects the current LoggerContext into this object.- Specified by:
setLoggerContextin interfaceLoggerContextAware- Parameters:
loggerContext- the current LoggerContext
-
-