Class Logger
- java.lang.Object
-
- org.apache.druid.java.util.common.logger.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceLogger.LogFunction
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voiddebug(String message, Object... formatArgs)voiddebug(Throwable t, String message, Object... formatArgs)voiddebug(org.slf4j.Marker marker, String message, Object... formatArgs)voiddebugSegments(Collection<DataSegment> segments, String preamble)voiderror(String message, Object... formatArgs)voiderror(String message, Throwable t)Deprecated.voiderror(Throwable t, String message, Object... formatArgs)voiderror(org.slf4j.Marker marker, String message, Object... formatArgs)voiderrorSegments(Collection<DataSegment> segments, String preamble)StringgetName()protected org.slf4j.LoggergetSlf4jLogger()voidinfo(String message, Object... formatArgs)voidinfo(Throwable t, String message, Object... formatArgs)voidinfo(org.slf4j.Marker marker, String message, Object... formatArgs)voidinfoSegmentIds(Stream<SegmentId> segments, String preamble)voidinfoSegments(Collection<DataSegment> segments, String preamble)booleanisDebugEnabled()booleanisInfoEnabled()booleanisTraceEnabled()LoggernoStackTrace()Returns a copy of this Logger that does not log exception stack traces orDruidException.getContext(), unless the log level is DEBUG or lower.StringtoString()voidtrace(String message, Object... formatArgs)voidtrace(org.slf4j.Marker marker, String message, Object... formatArgs)voidwarn(String message, Object... formatArgs)voidwarn(String message, Throwable t)Deprecated.voidwarn(Throwable t, String message, Object... formatArgs)voidwarn(org.slf4j.Marker marker, String message, Object... formatArgs)voidwarnSegments(Collection<DataSegment> segments, String preamble)
-
-
-
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 orDruidException.getContext(), unless the log level is DEBUG or lower. Useful for writing code like:log.noStackTrace().warn(e, "Something happened.");
-
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 messaget- The Throwable to log
-
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 messaget- The Throwable to log
-
debugSegments
public void debugSegments(@Nullable Collection<DataSegment> segments, @Nullable String preamble)
-
infoSegments
public void infoSegments(@Nullable Collection<DataSegment> segments, @Nullable String preamble)
-
infoSegmentIds
public void infoSegmentIds(@Nullable Stream<SegmentId> segments, @Nullable String preamble)
-
warnSegments
public void warnSegments(@Nullable Collection<DataSegment> segments, @Nullable String preamble)
-
errorSegments
public void errorSegments(@Nullable Collection<DataSegment> segments, @Nullable String preamble)
-
isTraceEnabled
public boolean isTraceEnabled()
-
isDebugEnabled
public boolean isDebugEnabled()
-
isInfoEnabled
public boolean isInfoEnabled()
-
getName
public String getName()
-
-