Class LogCtl

java.lang.Object
org.apache.jena.atlas.logging.LogCtl

public class LogCtl extends Object
Setup and control of logging. 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)
Implementation Note:
This needs access to log4j2 binaries including log4j-core, which is encapsulated in LogCtlLog4j2.
  • Field Details

    • log4j2ConfigFileProperty

      public static final String log4j2ConfigFileProperty
      The log4j2 configuration file - must be a file or URL, not a classpath java resource.
      See Also:
    • log4j2ConfigFilePropertyLegacy

      public static final String log4j2ConfigFilePropertyLegacy
      Legacy name for log4j2 configuration file
      See Also:
  • Constructor Details

    • LogCtl

      public LogCtl()
  • Method Details

    • set

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

      public static void setLevel(Class<?> cls, String level)
    • setLevel

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

      public static void setLevel(String logger, String level)
    • getLevel

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

      public static String getLevel(Class<?> logger)
    • getLevel

      public static String getLevel(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(String logger)
    • enable

      public static void enable(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(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(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(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(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(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(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(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(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:
    • setJavaLogging

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

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

      public static void withLevel(org.slf4j.Logger logger, String execLevel, Runnable action)
      Execute with a given logging level.