Class Logger

  • Direct Known Subclasses:
    EmittingLogger

    public class Logger
    extends Object
    A Logger for usage inside of Druid. Provides a layer that allows for simple changes to the logging framework with minimal changes to the Druid code. Log levels are used as an indication of urgency around the behavior that is being logged. The intended generic rubric for when to use the different logging levels is as follows. DEBUG: something that a developer wants to look at while actively debugging, but should not be included by default. INFO: a message that is useful to have when trying to retro-actively understand what happened in a running system. There is often a fine line between INFO and DEBUG. We want information from INFO logs but do not want to spam log files either. One rubric to use to help determine if something should be INFO or DEBUG is how often we expect the line to be logged. If there is clarity that it will happen in a controlled manner such that it does not spam the logs, then INFO is fine. Additionally, it can be okay to log at INFO level even if there is a risk of spamming the log file in the case that the log line only happens in specific "error-oriented" situations, this is because such error-oriented situations are more likely to necessitate reading and understanding the logs to eliminate the error. Additionally, it is perfectly acceptable and reasonable to log an exception at INFO level. WARN: a message that indicates something bad has happened in the system that a human should potentially investigate. While it is bad and deserves investigation, it is of a nature that it should be able to wait until the next "business day" for investigation instead of needing immediate attention. ERROR: a message that indicates that something bad has happened such that a human operator should take immediate intervention to triage and resolve the issue as it runs a risk to the smooth operations of the system. Logs at the ERROR level should generally be severe enough to warrant paging someone in the middle of the night. Even though this is the intended rubric, it is very difficult to ensure that, e.g. all ERROR log lines are pageable offenses. As such, it is questionable whether an operator should actually ALWAYS page on every ERROR log line, but as a directional target of when and how to log things, the above rubric should be used to evaluate if a log line is at the correct level.
    • Constructor Detail

      • Logger

        public Logger​(String name)
      • Logger

        public Logger​(Class clazz)
      • Logger

        protected Logger​(org.slf4j.Logger log,
                         boolean stackTraces)
    • Method Detail

      • getSlf4jLogger

        protected org.slf4j.Logger getSlf4jLogger()
      • noStackTrace

        public Logger noStackTrace()
        Returns a copy of this Logger that does not log exception stack traces, unless the log level is DEBUG or lower. Useful for writing code like: log.noStackTrace().warn(e, "Something happened.");
      • trace

        public void trace​(String message,
                          Object... formatArgs)
      • trace

        public void trace​(org.slf4j.Marker marker,
                          String message,
                          Object... formatArgs)
      • debug

        public void debug​(String message,
                          Object... formatArgs)
      • debug

        public void debug​(org.slf4j.Marker marker,
                          String message,
                          Object... formatArgs)
      • info

        public void info​(String message,
                         Object... formatArgs)
      • info

        public void info​(org.slf4j.Marker marker,
                         String message,
                         Object... formatArgs)
      • warn

        @Deprecated
        public void warn​(String message,
                         Throwable t)
        Deprecated.
        Protect against assuming slf4j convention. use `warn(Throwable t, String message, Object... formatArgs)` instead
        Parameters:
        message - The string message
        t - The Throwable to log
      • warn

        public void warn​(String message,
                         Object... formatArgs)
      • warn

        public void warn​(org.slf4j.Marker marker,
                         String message,
                         Object... formatArgs)
      • error

        public void error​(String message,
                          Object... formatArgs)
      • error

        public void error​(org.slf4j.Marker marker,
                          String message,
                          Object... formatArgs)
      • error

        @Deprecated
        public void error​(String message,
                          Throwable t)
        Deprecated.
        Protect against assuming slf4j convention. use `error(Throwable t, String message, Object... formatArgs)` instead
        Parameters:
        message - The string message
        t - The Throwable to log
      • assertionError

        public void assertionError​(String message,
                                   Object... formatArgs)
      • isTraceEnabled

        public boolean isTraceEnabled()
      • isDebugEnabled

        public boolean isDebugEnabled()
      • isInfoEnabled

        public boolean isInfoEnabled()
      • getName

        public String getName()