Package org.apache.logging.log4j.util
Class SystemPropertiesPropertySource
- java.lang.Object
-
- org.apache.logging.log4j.util.SystemPropertiesPropertySource
-
- All Implemented Interfaces:
PropertySource
public class SystemPropertiesPropertySource extends java.lang.Object 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 Modifier and Type Field Description private static intDEFAULT_PRIORITYprivate static java.lang.StringPREFIX
-
Constructor Summary
Constructors Constructor Description SystemPropertiesPropertySource()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsProperty(java.lang.String key)For PropertySources that cannot iterate over all the potential properties this provides a direct lookup.voidforEach(BiConsumer<java.lang.String,java.lang.String> action)Iterates over all properties and performs an action for each key/value pair.java.lang.CharSequencegetNormalForm(java.lang.Iterable<? extends java.lang.CharSequence> tokens)Converts a list of property name tokens into a normal form.intgetPriority()Returns the order in which this PropertySource has priority.java.lang.StringgetProperty(java.lang.String key)For PropertySources that cannot iterate over all the potential properties this provides a direct lookup.java.util.Collection<java.lang.String>getPropertyNames()Returns the list of all property names.static java.lang.StringgetSystemProperty(java.lang.String key, java.lang.String defaultValue)Used by bootstrap code to get system properties without loading PropertiesUtil.
-
-
-
Field Detail
-
DEFAULT_PRIORITY
private static final int DEFAULT_PRIORITY
- See Also:
- Constant Field Values
-
PREFIX
private static final java.lang.String PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSystemProperty
public static java.lang.String getSystemProperty(java.lang.String key, java.lang.String defaultValue)Used by bootstrap code to get system properties without loading PropertiesUtil.
-
getPriority
public int getPriority()
Description copied from interface:PropertySourceReturns 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:
getPriorityin interfacePropertySource- Returns:
- priority value
-
forEach
public void forEach(BiConsumer<java.lang.String,java.lang.String> action)
Description copied from interface:PropertySourceIterates over all properties and performs an action for each key/value pair.- Specified by:
forEachin interfacePropertySource- Parameters:
action- action to perform on each key/value pair
-
getNormalForm
public java.lang.CharSequence getNormalForm(java.lang.Iterable<? extends java.lang.CharSequence> tokens)
Description copied from interface:PropertySourceConverts a list of property name tokens into a normal form. For example, a list of tokens such as "foo", "bar", "baz", might be normalized into the property name "log4j2.fooBarBaz".- Specified by:
getNormalFormin interfacePropertySource- Parameters:
tokens- list of property name tokens- Returns:
- a normalized property name using the given tokens
-
getPropertyNames
public java.util.Collection<java.lang.String> getPropertyNames()
Description copied from interface:PropertySourceReturns the list of all property names.- Specified by:
getPropertyNamesin interfacePropertySource- Returns:
- list of property names
-
getProperty
public java.lang.String getProperty(java.lang.String key)
Description copied from interface:PropertySourceFor PropertySources that cannot iterate over all the potential properties this provides a direct lookup.- Specified by:
getPropertyin interfacePropertySource- Parameters:
key- The key to search for.- Returns:
- The value or null;
-
containsProperty
public boolean containsProperty(java.lang.String key)
Description copied from interface:PropertySourceFor PropertySources that cannot iterate over all the potential properties this provides a direct lookup.- Specified by:
containsPropertyin interfacePropertySource- Parameters:
key- The key to search for.- Returns:
- The value or null;
-
-