Class JDALogger

java.lang.Object
net.dv8tion.jda.internal.utils.JDALogger

public class JDALogger extends Object
This class serves as a LoggerFactory for JDA's internals.
It will either return a Logger from a SLF4J implementation via LoggerFactory if present, or an instance of a custom FallbackLogger.

It also has the utility method getLazyString(LazyEvaluation) which is used to lazily construct Strings for Logging.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Functional interface used for getLazyString(LazyEvaluation) to lazily construct a String.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The name of the system property, which controls whether the fallback logger is disabled.
    static final boolean
    Whether an implementation of SLF4JServiceProvider was found.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Object
    Utility function to enable logging of complex statements more efficiently (lazy).
    static org.slf4j.Logger
    getLog(Class<?> clazz)
    Will get the Logger for the given Class or create and cache a fallback logger if there is no SLF4J implementation present.
    static org.slf4j.Logger
    getLog(String name)
    Will get the Logger with the given log-name or create and cache a fallback logger if there is no SLF4J implementation present.
    static void
    setFallbackLoggerEnabled(boolean enabled)
    Disables the automatic fallback logger that JDA uses when no SLF4J implementation is found.

    Methods inherited from class java.lang.Object

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

    • DISABLE_FALLBACK_PROPERTY_NAME

      public static final String DISABLE_FALLBACK_PROPERTY_NAME
      The name of the system property, which controls whether the fallback logger is disabled.

      "net.dv8tion.jda.disableFallbackLogger"

      See Also:
    • SLF4J_ENABLED

      public static final boolean SLF4J_ENABLED
      Whether an implementation of SLF4JServiceProvider was found.
      If false, JDA will use its fallback logger.

      The fallback logger can be disabled with setFallbackLoggerEnabled(boolean) or using the system property "net.dv8tion.jda.disableFallbackLogger".

  • Method Details

    • setFallbackLoggerEnabled

      public static void setFallbackLoggerEnabled(boolean enabled)
      Disables the automatic fallback logger that JDA uses when no SLF4J implementation is found.
      Parameters:
      enabled - False, to disable the fallback logger
    • getLog

      public static org.slf4j.Logger getLog(String name)
      Will get the Logger with the given log-name or create and cache a fallback logger if there is no SLF4J implementation present.

      The fallback logger uses a constant logging configuration and prints directly to System.err.

      Parameters:
      name - The name of the Logger
      Returns:
      Logger with given log name
    • getLog

      public static org.slf4j.Logger getLog(Class<?> clazz)
      Will get the Logger for the given Class or create and cache a fallback logger if there is no SLF4J implementation present.

      The fallback logger uses a constant logging configuration and prints directly to System.err.

      Parameters:
      clazz - The class used for the Logger name
      Returns:
      Logger for given Class
    • getLazyString

      public static Object getLazyString(JDALogger.LazyEvaluation lazyLambda)
      Utility function to enable logging of complex statements more efficiently (lazy).
      Parameters:
      lazyLambda - The Supplier used when evaluating the expression
      Returns:
      An Object that can be passed to SLF4J's logging methods as lazy parameter