Class Logger
java.lang.Object
org.apache.druid.java.util.common.logger.Logger
- Direct Known Subclasses:
EmittingLogger
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.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidvoiddebugSegments(Collection<DataSegment> segments, String preamble) voidvoidDeprecated.voidvoidvoiderrorSegments(Throwable throwable, Collection<DataSegment> segments, String preamble) Logs error exception first and then logs the segmentsvoiderrorSegments(Collection<DataSegment> segments, String preamble) getName()protected org.slf4j.LoggervoidvoidvoidvoidinfoSegmentIds(Stream<SegmentId> segments, String preamble) voidinfoSegments(Collection<DataSegment> segments, String preamble) booleanbooleanbooleanReturns a copy of this Logger that does not log exception stack traces orDruidException.getContext(), unless the log level is DEBUG or lower.toString()voidvoidvoidvoidDeprecated.voidvoidvoidwarnSegments(Collection<DataSegment> segments, String preamble)
-
Constructor Details
-
Logger
-
Logger
-
Logger
protected Logger(org.slf4j.Logger log, boolean stackTraces)
-
-
Method Details
-
getSlf4jLogger
protected org.slf4j.Logger getSlf4jLogger() -
toString
-
noStackTrace
Returns a copy of this Logger that does not log exception stack traces orDruidException.getContext(), unless the log level is DEBUG or lower. Useful for writing code like:log.noStackTrace().warn(e, "Something happened."); -
trace
-
trace
-
debug
-
debug
-
debug
-
info
-
info
-
info
-
warn
Deprecated.Protect against assuming slf4j convention. use `warn(Throwable t, String message, Object... formatArgs)` instead- Parameters:
message- The string messaget- The Throwable to log
-
warn
-
warn
-
warn
-
error
-
error
-
error
Deprecated.Protect against assuming slf4j convention. use `error(Throwable t, String message, Object... formatArgs)` instead- Parameters:
message- The string messaget- The Throwable to log
-
error
-
debugSegments
-
infoSegments
-
infoSegmentIds
-
warnSegments
-
errorSegments
-
errorSegments
public void errorSegments(Throwable throwable, @Nullable Collection<DataSegment> segments, String preamble) Logs error exception first and then logs the segments -
isTraceEnabled
public boolean isTraceEnabled() -
isDebugEnabled
public boolean isDebugEnabled() -
isInfoEnabled
public boolean isInfoEnabled() -
getName
-