Class CamelLogger

java.lang.Object
org.apache.camel.spi.CamelLogger

public class CamelLogger extends Object
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 Details

    • CamelLogger

      public CamelLogger()
    • CamelLogger

      public CamelLogger(org.slf4j.Logger log)
    • CamelLogger

      public CamelLogger(org.slf4j.Logger log, LoggingLevel level)
    • CamelLogger

      public CamelLogger(org.slf4j.Logger log, LoggingLevel level, @Nullable String marker)
    • CamelLogger

      public CamelLogger(String logName)
    • CamelLogger

      public CamelLogger(String logName, LoggingLevel level)
    • CamelLogger

      public CamelLogger(String logName, LoggingLevel level, @Nullable String marker)
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • log

      public void log(@Nullable String message, LoggingLevel loggingLevel)
    • log

      public void log(@Nullable String message)
      Logs the message with checking the shouldLog() method first.
      Parameters:
      message - the message to log, if shouldLog() returned true
    • doLog

      public void doLog(@Nullable String message)
      Logs the message without checking the shouldLog() method first.
      Parameters:
      message - the message to log
    • log

      public void log(@Nullable String message, Throwable exception, LoggingLevel loggingLevel)
    • log

      public void log(@Nullable String message, Throwable exception)
    • getLog

      public org.slf4j.Logger getLog()
    • setLog

      public void setLog(org.slf4j.Logger log)
    • getLevel

      public LoggingLevel getLevel()
    • setLevel

      public void setLevel(LoggingLevel level)
    • setLogName

      public void setLogName(String logName)
    • getMarker

      public @Nullable org.slf4j.Marker getMarker()
    • setMarker

      public void setMarker(@Nullable org.slf4j.Marker marker)
    • setMarker

      public void setMarker(@Nullable String marker)
    • log

      public static void log(org.slf4j.Logger log, LoggingLevel level, @Nullable String message)
    • 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

      public static boolean shouldLog(org.slf4j.Logger log, LoggingLevel level)