Class EnvironmentPropertySource

  • All Implemented Interfaces:
    PropertySource, ReloadablePropertySource

    public class EnvironmentPropertySource
    extends ContextAwarePropertySource
    implements ReloadablePropertySource
    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
    • Constructor Detail

      • EnvironmentPropertySource

        public EnvironmentPropertySource()
    • Method Detail

      • 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 interface PropertySource
        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 interface PropertySource
        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 interface PropertySource
        Parameters:
        tokens - list of property name tokens
        Returns:
        a normalized property name using the given tokens