Module org.apache.logging.log4j
Package org.apache.logging.log4j.util
Class SystemPropertiesPropertySource
- java.lang.Object
-
- org.apache.logging.log4j.util.ContextAwarePropertySource
-
- org.apache.logging.log4j.util.SystemPropertiesPropertySource
-
- All Implemented Interfaces:
PropertySource
public class SystemPropertiesPropertySource extends ContextAwarePropertySource implements PropertySource
PropertySource backed by the current system properties. Other than having a higher priority over normal properties, this follows the same rules asPropertiesPropertySource
.- Since:
- 2.10.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.logging.log4j.util.PropertySource
PropertySource.Comparator, PropertySource.Util
-
-
Field Summary
-
Fields inherited from class org.apache.logging.log4j.util.ContextAwarePropertySource
propertiesMap
-
Fields inherited from interface org.apache.logging.log4j.util.PropertySource
MAPPING_FILE, SYSTEM_CONTEXT
-
-
Constructor Summary
Constructors Constructor Description SystemPropertiesPropertySource()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsProperty(String contextName, String key)
void
forEach(BiConsumer<String,String> action)
Iterates over all properties and performs an action for each key/value pair.CharSequence
getNormalForm(Iterable<? extends CharSequence> tokens)
Converts a list of property name tokens into a normal form.int
getPriority()
Returns the order in which this PropertySource has priority.Map<String,Properties>
getPropertiesMap()
String
getProperty(String contextName, String key)
Collection<String>
getPropertyNames()
Returns the list of all property names for the System Context.Collection<String>
getPropertyNames(String contextName)
static String
getSystemProperty(String key, String defaultValue)
Used by bootstrap code to get system properties without loading PropertiesUtil.-
Methods inherited from class org.apache.logging.log4j.util.ContextAwarePropertySource
containsProperty, getProperty, parseProperties, parseProperties, parseProperties
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.logging.log4j.util.PropertySource
containsProperty, getProperty
-
-
-
-
Method Detail
-
getSystemProperty
public static String getSystemProperty(String key, String defaultValue)
Used by bootstrap code to get system properties without loading PropertiesUtil.
-
getPriority
public int getPriority()
Description copied from interface:PropertySource
Returns the order in which this PropertySource has priority. A higher value means that the source will be searched later and can be overridden by other property sources.- Specified by:
getPriority
in interfacePropertySource
- Returns:
- priority value
-
forEach
public void forEach(BiConsumer<String,String> action)
Description copied from interface:PropertySource
Iterates over all properties and performs an action for each key/value pair.- Specified by:
forEach
in interfacePropertySource
- Parameters:
action
- action to perform on each key/value pair
-
getNormalForm
public CharSequence getNormalForm(Iterable<? extends CharSequence> tokens)
Description copied from interface:PropertySource
Converts a list of property name tokens into a normal form. For example, by default a list of tokens such as "foo", "bar", "baz", will be normalized into the property name "log4j2.foo.bar.baz". Note that this is normally used in conjunction with Util.tokenize() which breaks a string into tokens and then this puts them back together.- Specified by:
getNormalForm
in interfacePropertySource
- Parameters:
tokens
- list of property name tokens- Returns:
- a normalized property name using the given tokens
-
getPropertyNames
public Collection<String> getPropertyNames()
Description copied from interface:PropertySource
Returns the list of all property names for the System Context.- Specified by:
getPropertyNames
in interfacePropertySource
- Overrides:
getPropertyNames
in classContextAwarePropertySource
- Returns:
- list of property names
-
getPropertyNames
public Collection<String> getPropertyNames(String contextName)
- Overrides:
getPropertyNames
in classContextAwarePropertySource
-
getProperty
public String getProperty(String contextName, String key)
- Overrides:
getProperty
in classContextAwarePropertySource
-
containsProperty
public boolean containsProperty(String contextName, String key)
- Overrides:
containsProperty
in classContextAwarePropertySource
-
getPropertiesMap
public Map<String,Properties> getPropertiesMap()
- Overrides:
getPropertiesMap
in classContextAwarePropertySource
-
-