Class LoggingHandler

All Implemented Interfaces:
org.reactivestreams.Subscriber<org.springframework.messaging.Message<?>>, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.core.Ordered, ExpressionCapable, Orderable, IntegrationPattern, NamedComponent, IntegrationManagement, TrackableComponent, org.springframework.messaging.MessageHandler, reactor.core.CoreSubscriber<org.springframework.messaging.Message<?>>

public class LoggingHandler extends AbstractMessageHandler
MessageHandler implementation that simply logs the Message or its payload depending on the value of the 'shouldLogFullMessage' or SpEL 'logExpression' property. If logging the payload, and it is assignable to Throwable, it will log the stack trace. By default, it will log the payload only.
Since:
1.0.1
  • Constructor Details

  • Method Details

    • setLogExpressionString

      public void setLogExpressionString(String expressionString)
      Set a SpEL expression string to use.
      Parameters:
      expressionString - the SpEL expression string to use.
      Since:
      4.3
      See Also:
    • setLogExpression

      public void setLogExpression(org.springframework.expression.Expression expression)
      Set an Expression to evaluate a log entry at runtime against the request Message.
      Parameters:
      expression - the Expression to use.
      Since:
      4.3
      See Also:
    • getLevel

      public LoggingHandler.Level getLevel()
      Returns:
      The current logging LoggingHandler.Level.
    • setLevel

      public void setLevel(LoggingHandler.Level level)
      Set the logging LoggingHandler.Level to change the behavior at runtime.
      Parameters:
      level - the level.
    • setLoggerName

      public void setLoggerName(String loggerName)
    • setShouldLogFullMessage

      public void setShouldLogFullMessage(boolean shouldLogFullMessage)
      Specify whether to log the full Message. Otherwise, only the payload will be logged. This value is false by default.
      Parameters:
      shouldLogFullMessage - true if the complete message should be logged.
    • getComponentType

      public String getComponentType()
      Description copied from class: IntegrationObjectSupport
      Subclasses may implement this method to provide component type information.
      Specified by:
      getComponentType in interface NamedComponent
      Overrides:
      getComponentType in class MessageHandlerSupport
    • onInit

      protected void onInit()
      Description copied from class: IntegrationObjectSupport
      Subclasses may implement this for initialization logic.
      Overrides:
      onInit in class IntegrationObjectSupport
    • handleMessageInternal

      protected void handleMessageInternal(org.springframework.messaging.Message<?> message)
      Specified by:
      handleMessageInternal in class AbstractMessageHandler