Search in sources :

Example 6 with LoggingHandler

use of org.springframework.integration.handler.LoggingHandler in project spring-integration by spring-projects.

the class IntegrationFlowDefinition method log.

/**
 * Populate a {@link WireTap} for the {@link #currentMessageChannel}
 * with the {@link LoggingHandler} subscriber for the provided
 * {@link LoggingHandler.Level} logging level, logging category
 * and SpEL expression for the log message.
 * @param level the {@link LoggingHandler.Level}.
 * @param category the logging category.
 * @param logExpression the {@link Expression} to evaluate logger message at runtime
 * against the request {@link Message}.
 * @return the current {@link IntegrationFlowDefinition}.
 * @see #wireTap(WireTapSpec)
 */
public B log(LoggingHandler.Level level, String category, Expression logExpression) {
    LoggingHandler loggingHandler = new LoggingHandler(level);
    if (StringUtils.hasText(category)) {
        loggingHandler.setLoggerName(category);
    }
    if (logExpression != null) {
        loggingHandler.setLogExpression(logExpression);
    } else {
        loggingHandler.setShouldLogFullMessage(true);
    }
    addComponent(loggingHandler);
    MessageChannel loggerChannel = new FixedSubscriberChannel(loggingHandler);
    return wireTap(loggerChannel);
}
Also used : LoggingHandler(org.springframework.integration.handler.LoggingHandler) FluxMessageChannel(org.springframework.integration.channel.FluxMessageChannel) MessageChannel(org.springframework.messaging.MessageChannel) FixedSubscriberChannel(org.springframework.integration.channel.FixedSubscriberChannel)

Aggregations

LoggingHandler (org.springframework.integration.handler.LoggingHandler)6 Test (org.junit.Test)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Log (org.apache.commons.logging.Log)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 Bean (org.springframework.context.annotation.Bean)1 ServiceActivator (org.springframework.integration.annotation.ServiceActivator)1 FixedSubscriberChannel (org.springframework.integration.channel.FixedSubscriberChannel)1 FluxMessageChannel (org.springframework.integration.channel.FluxMessageChannel)1 AbstractReplyProducingMessageHandler (org.springframework.integration.handler.AbstractReplyProducingMessageHandler)1 MessageChannel (org.springframework.messaging.MessageChannel)1 MessageHandler (org.springframework.messaging.MessageHandler)1