Class CamelLogger
java.lang.Object
org.apache.camel.spi.CamelLogger
A configurable SLF4J logger wrapper that carries a
LoggingLevel and an optional SLF4J Marker.
Camel components and EIPs that need to emit log output accept a CamelLogger rather than a raw SLF4J
Logger so that the log level and marker can be configured externally (e.g., via endpoint URI or route DSL)
without changing the logging code. The log(String) method respects the configured level and only writes if
the underlying logger has that level enabled; doLog(String) skips the level check and always writes, which
is useful when the check was already performed by the caller.
The name CamelLogger was chosen to avoid a class-name clash with the Logger class present in many
older logging frameworks (Log4j 1.x, Commons Logging, etc.) that may be on the classpath.
See Log EIP in the Camel user manual.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCamelLogger(String logName) CamelLogger(String logName, LoggingLevel level) CamelLogger(String logName, LoggingLevel level, @Nullable String marker) CamelLogger(org.slf4j.Logger log) CamelLogger(org.slf4j.Logger log, LoggingLevel level) CamelLogger(org.slf4j.Logger log, LoggingLevel level, @Nullable String marker) -
Method Summary
Modifier and TypeMethodDescriptionvoidLogs the message without checking theshouldLog()method first.getLevel()org.slf4j.LoggergetLog()@Nullable org.slf4j.MarkervoidLogs the message with checking theshouldLog()method first.voidvoidlog(@Nullable String message, Throwable exception, LoggingLevel loggingLevel) voidlog(@Nullable String message, LoggingLevel loggingLevel) static voidlog(org.slf4j.Logger log, LoggingLevel level, @Nullable String message) static voidlog(org.slf4j.Logger log, LoggingLevel level, @Nullable String message, Throwable th) static voidlog(org.slf4j.Logger log, LoggingLevel level, @Nullable org.slf4j.Marker marker, @Nullable String message, Throwable th) static voidlog(org.slf4j.Logger log, LoggingLevel level, org.slf4j.Marker marker, @Nullable String message) voidsetLevel(LoggingLevel level) voidsetLog(org.slf4j.Logger log) voidsetLogName(String logName) voidvoidsetMarker(@Nullable org.slf4j.Marker marker) booleanstatic booleanshouldLog(org.slf4j.Logger log, LoggingLevel level) toString()
-
Constructor Details
-
CamelLogger
public CamelLogger() -
CamelLogger
public CamelLogger(org.slf4j.Logger log) -
CamelLogger
-
CamelLogger
-
CamelLogger
-
CamelLogger
-
CamelLogger
-
-
Method Details
-
toString
-
log
-
log
Logs the message with checking theshouldLog()method first.- Parameters:
message- the message to log, ifshouldLog()returned true
-
doLog
Logs the message without checking theshouldLog()method first.- Parameters:
message- the message to log
-
log
-
log
-
getLog
public org.slf4j.Logger getLog() -
setLog
public void setLog(org.slf4j.Logger log) -
getLevel
-
setLevel
-
setLogName
-
getMarker
public @Nullable org.slf4j.Marker getMarker() -
setMarker
public void setMarker(@Nullable org.slf4j.Marker marker) -
setMarker
-
log
-
log
public static void log(org.slf4j.Logger log, LoggingLevel level, org.slf4j.Marker marker, @Nullable String message) -
log
public static void log(org.slf4j.Logger log, LoggingLevel level, @Nullable String message, Throwable th) -
log
public static void log(org.slf4j.Logger log, LoggingLevel level, @Nullable org.slf4j.Marker marker, @Nullable String message, Throwable th) -
shouldLog
public boolean shouldLog() -
shouldLog
-