Package org.apache.logging.log4j.util
Class EnvironmentPropertySource
java.lang.Object
org.apache.logging.log4j.util.EnvironmentPropertySource
- All Implemented Interfaces:
PropertySource
PropertySource implementation that uses environment variables as a source.
All environment variables must begin with
LOG4J_ so as not to
conflict with other variables. Normalized environment variables follow a
scheme like this: log4j2.fooBarProperty would normalize to
LOG4J_FOO_BAR_PROPERTY.- Since:
- 2.10.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.logging.log4j.util.PropertySource
PropertySource.Comparator, PropertySource.Util -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsProperty(String key) For PropertySources that cannot iterate over all the potential properties this provides a direct lookup.voidforEach(BiConsumer<String, String> action) Iterates over all properties and performs an action for each key/value pair.getNormalForm(Iterable<? extends CharSequence> tokens) Converts a list of property name tokens into a normal form.intReturns the order in which this PropertySource has priority.getProperty(String key) For PropertySources that cannot iterate over all the potential properties this provides a direct lookup.Returns the list of all property names.static PropertySourceprovider()Method used by Java 9+ to instantiate providers
-
Constructor Details
-
EnvironmentPropertySource
public EnvironmentPropertySource()
-
-
Method Details
-
provider
Method used by Java 9+ to instantiate providers- Since:
- 2.24.0
- See Also:
-
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
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
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
Description copied from interface:PropertySourceReturns the list of all property names.- Specified by:
getPropertyNamesin interfacePropertySource- Returns:
- list of property names
-
getProperty
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
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;
-