Class LogCtl


  • public class LogCtl
    extends java.lang.Object
    Setup and control of logging - needs access to log4j2 binaries. Sources of configuration:
    • Standard setup (e.g. for log4j2, property log4j.configurationFile
    • jena-cmds: the shell scripts set logging to "apache-jena/log4j2.properties." (uses stderr)
    • Default logging for log4j2: java resource src/main/resources/log4j-jena.properties (uses stdout)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String log4j2ConfigProperty
      The log4j2 configuration file - must be a file or URL, not a classpath java resource
    • Constructor Summary

      Constructors 
      Constructor Description
      LogCtl()  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static void disable​(java.lang.Class<?> logger)
      Turn on a logger (all levels).
      static void disable​(java.lang.String logger)
      Turn on a logger (all levels).
      static void disable​(org.slf4j.Logger logger)
      Turn on a logger (all levels).
      static void enable​(java.lang.Class<?> logger)
      Turn on a logger (all levels).
      static void enable​(java.lang.String logger)  
      static void enable​(org.slf4j.Logger logger)
      Turn on a logger (all levels).
      static java.lang.String getLevel​(java.lang.Class<?> logger)  
      static java.lang.String getLevel​(java.lang.String logger)  
      static java.lang.String getLevel​(org.slf4j.Logger logger)  
      static void set​(org.slf4j.Logger logger, java.lang.String level)  
      static void setCmdLogging()
      Deprecated.
      static void setError​(java.lang.Class<?> logger)
      Set to error level.
      static void setError​(java.lang.String logger)
      Set to error level.
      static void setInfo​(java.lang.Class<?> logger)
      Set to info level.
      static void setInfo​(java.lang.String logger)
      Set to info level.
      static void setJavaLogging()
      Setup java.util.logging if it has not been set before; otherwise do nothing.
      static void setJavaLogging​(java.lang.String filename)
      Setup java.util.logging with the configuration from a file.
      static void setLevel​(java.lang.Class<?> cls, java.lang.String level)  
      static void setLevel​(java.lang.String logger, java.lang.String level)  
      static void setLevel​(org.slf4j.Logger logger, java.lang.String level)  
      static void setLog4j2()
      Setup log4j2, including looking for a file "log4j2.properties" or "log4j2.xml" in the current working directory.
      static void setLogging()
      Set logging.
      static void setWarn​(java.lang.Class<?> logger)
      Set to warning level.
      static void setWarn​(java.lang.String logger)
      Set to warning level.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • log4j2ConfigProperty

        public static final java.lang.String log4j2ConfigProperty
        The log4j2 configuration file - must be a file or URL, not a classpath java resource
        See Also:
        Constant Field Values
    • Constructor Detail

      • LogCtl

        public LogCtl()
    • Method Detail

      • set

        public static void set​(org.slf4j.Logger logger,
                               java.lang.String level)
      • setLevel

        public static void setLevel​(java.lang.Class<?> cls,
                                    java.lang.String level)
      • setLevel

        public static void setLevel​(org.slf4j.Logger logger,
                                    java.lang.String level)
      • setLevel

        public static void setLevel​(java.lang.String logger,
                                    java.lang.String level)
      • getLevel

        public static java.lang.String getLevel​(org.slf4j.Logger logger)
      • getLevel

        public static java.lang.String getLevel​(java.lang.Class<?> logger)
      • getLevel

        public static java.lang.String getLevel​(java.lang.String logger)
      • enable

        public static void enable​(org.slf4j.Logger logger)
        Turn on a logger (all levels). Works for Log4j and Java logging as the logging provider to Apache common logging or slf4j.
      • enable

        public static void enable​(java.lang.String logger)
      • enable

        public static void enable​(java.lang.Class<?> logger)
        Turn on a logger (all levels). Works for Log4j and Java logging as the logging provider to Apache common logging or slf4j.
      • disable

        public static void disable​(org.slf4j.Logger logger)
        Turn on a logger (all levels). Works for Log4j and Java logging as the logging provider to Apache common logging or slf4j.
      • disable

        public static void disable​(java.lang.String logger)
        Turn on a logger (all levels). Works for Log4j and Java logging as the logging provider to Apache common logging or slf4j.
      • disable

        public static void disable​(java.lang.Class<?> logger)
        Turn on a logger (all levels). Works for Log4j and Java logging as the logging provider to Apache common logging or slf4j.
      • setInfo

        public static void setInfo​(java.lang.String logger)
        Set to info level. Works for Log4j and Java logging as the logging provider to Apache common logging or slf4j.
      • setInfo

        public static void setInfo​(java.lang.Class<?> logger)
        Set to info level. Works for Log4j and Java logging as the logging provider to Apache common logging or slf4j.
      • setWarn

        public static void setWarn​(java.lang.String logger)
        Set to warning level. Works for Log4j and Java logging as the logging provider to Apache common logging or slf4j.
      • setWarn

        public static void setWarn​(java.lang.Class<?> logger)
        Set to warning level. Works for Log4j and Java logging as the logging provider to Apache common logging or slf4j.
      • setError

        public static void setError​(java.lang.String logger)
        Set to error level. Works for Log4j and Java logging as the logging provider to Apache common logging or slf4j.
      • setError

        public static void setError​(java.lang.Class<?> logger)
        Set to error level. Works for Log4j and Java logging as the logging provider to Apache common logging or slf4j.
      • setLogging

        public static void setLogging()
        Set logging.

        Normally, the logging provider mechanism should be used. This call will insert some kind of logging set for JUL and Log4j2 when no configuration is setup; output is to stdout.

        Ideally, initialize the logging provider using the mechanism specific to that provider. For example, see the log4j2 configuration documentation.

        To set application logging, choose one of:

        • For JUL logging, have a dependency on artifact org.slf4j:slf4j-jdk14.
        • For log4j2 logging, have a dependency on artifact org.apache.logging.log4j:log4j-slf4j-impl.
      • setCmdLogging

        @Deprecated
        public static void setCmdLogging()
        Deprecated.
      • setLog4j2

        public static void setLog4j2()
        Setup log4j2, including looking for a file "log4j2.properties" or "log4j2.xml" in the current working directory.
        See Also:
        setLogging()
      • setJavaLogging

        public static void setJavaLogging()
        Setup java.util.logging if it has not been set before; otherwise do nothing.
      • setJavaLogging

        public static void setJavaLogging​(java.lang.String filename)
        Setup java.util.logging with the configuration from a file.
        Parameters:
        filename -