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);
}
Aggregations