org.apache.logging.log4j.util

Class SystemPropertiesPropertySource

  • All Implemented Interfaces:
    PropertySource


    public class SystemPropertiesPropertySource
    extends Object
    implements PropertySource
    PropertySource backed by the current system properties. Other than having a higher priority over normal properties, this follows the same rules as PropertiesPropertySource.
    Since:
    2.10.0
    • Constructor Detail

      • SystemPropertiesPropertySource

        public SystemPropertiesPropertySource()
    • 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 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, a list of tokens such as "foo", "bar", "baz", might be normalized into the property name "log4j2.fooBarBaz".
        Specified by:
        getNormalForm in interface PropertySource
        Parameters:
        tokens - list of property name tokens
        Returns:
        a normalized property name using the given tokens
      • getProperty

        public String getProperty(String key)
        Description copied from interface: PropertySource
        For PropertySources that cannot iterate over all the potential properties this provides a direct lookup.
        Specified by:
        getProperty in interface PropertySource
        Parameters:
        key - The key to search for.
        Returns:
        The value or null;
      • containsProperty

        public boolean containsProperty(String key)
        Description copied from interface: PropertySource
        For PropertySources that cannot iterate over all the potential properties this provides a direct lookup.
        Specified by:
        containsProperty in interface PropertySource
        Parameters:
        key - The key to search for.
        Returns:
        The value or null;

Copyright © 1999-2023 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.