All Downloads are FREE. Search and download functionalities are using the official Maven repository.

biz.paluch.logging.RuntimeContainerProperties Maven / Gradle / Ivy

There is a newer version: 1.15.1
Show newest version
package biz.paluch.logging;

/**
 * Collection of property names in order to control host name/host name resolution.
 * 
 * @author Mark Paluch
 * @since 11.04.14 12:30
 */
public class RuntimeContainerProperties {
    /**
     * Set this system property to a simple hostname to use a fixed host name.
     */
    public static final String PROPERTY_LOGSTASH_GELF_HOSTNAME = "logstash-gelf.hostname";

    /**
     * Set this system property to a fully qualified hostname to use a fixed host name.
     */
    public static final String PROPERTY_LOGSTASH_GELF_FQDN_HOSTNAME = "logstash-gelf.fqdn.hostname";

    /**
     * Set this system property to true to skip hosname resolution. The string unknown will be used as
     * hostname.
     */
    public static final String PROPERTY_LOGSTASH_GELF_SKIP_HOSTNAME_RESOLUTION = "logstash-gelf.skipHostnameResolution";

    /**
     * Set this propery to {@link #RESOLUTION_ORDER_LOCALHOST_NETWORK_FALLBACK} or
     * {@link #RESOLUTION_ORDER_NETWORK_LOCALHOST_FALLBACK} to control the hostname resolution order.
     */
    public static final String PROPERTY_LOGSTASH_GELF_HOSTNAME_RESOLUTION_ORDER = "logstash-gelf.resolutionOrder";

    /**
     * Resolution order: First inspect the local host name, then try to get the host name from network devices.
     */
    public static final String RESOLUTION_ORDER_LOCALHOST_NETWORK_FALLBACK = "localhost,network";

    /**
     * Resolution order: First inspect the network devices to retrieve a host name, then try to get the host name from the local
     * host.
     */
    public static final String RESOLUTION_ORDER_NETWORK_LOCALHOST_FALLBACK = "network,localhost";

    private RuntimeContainerProperties() {

    }

    /**
     * Lookup property from ({@link System#getenv(String)} and {@link System#getProperty(String)} as fallback.
     * 
     * @param key
     * @param defaultValue
     * @return
     */
    public static String getProperty(String key, String defaultValue) {
        String env = System.getenv(key);
        if (env != null && !"".equals(env)) {
            return env;
        }
        return System.getProperty(key, defaultValue);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy