Class JulConfig


  • public class JulConfig
    extends Object
    Utility to override java.util.logging properties with values from system properties.

    Note: overriding can be applied to an existing java app at run time: just add java-utils jar to the class-path and define desired system properties.

    See Also:
    overrideLogLevels(String...)
    • Method Detail

      • overrideLogLevels

        public static void overrideLogLevels​(String... names)
        Overrides Levels of java.util.logging Loggers and Handlers with values obtained from system properties.

        Fully qualified names of Loggers and Handlers whose Levels should be overridden by this method are provided as arguments to this method and/or comma separated on "java.util.logging.overrideLevel" system property.
        Name of the system property containing the new Level for a given Logger/Handler is constructed by appending ".level" to its fully-qualified-name. If a system property with a new Level is missing, it is ignored. If it is present, its validity is verified using Level.parse(String) method.

        Example:
        Output all entries from com.example name-space with level FINE or higher to the console. Entries from other name-spaces will be logged only if they have at least level WARNING, unless configured otherwise in the default logging.properties file:

        java -Djava.util.logging.config.class=pl.morgwai.base.logging.JulConfig \
             -Djava.util.logging.overrideLevel=,com.example,java.util.logging.ConsoleHandler \
             -D.level=WARNING \
             -Dcom.example.level=FINE \
             -Djava.util.logging.ConsoleHandler.level=FINE \
             com.example.someproject.MainClass