Spring Channel integration registration errors (slf4j + logback)

I am using Spring integration with this configuration:

@Bean MessageChannel errorChannel(){
    return new PublishSubscribeChannel();
}

@MessagingGateway(name = "gatewayInbound", 
defaultRequestChannel="farsRequestChannel", errorChannel="errorChannel"){
}

In this configuration, I avoid showing messages, but I want to create a basic log such as LOGGER.error ().

In addition, I work with SLFJ and logbak. Thus, an ideal script would integrate this error message with a similar configuration in my logback XML. For this reason:

  • Can logback be used to log Spring LOGS integration errors?
  • Can I show the error sent to the errorChannel file?
  • Can I personalize this error with this similar expression in the log? If I use LoggingHandler, I see a full stack trace, and I want to configure this message.

    [% - 5level] -% d {dd / MM / YYYY HH: mm: ss} - [% file:% line] -% msg% n

+4
1
@Bean
@ServiceActivator(inputChannel="myErrorChannel")
public MessageHandler myLogger() {
    return new MessageHandler() {

        @Override
        public void handleMessage(Message<?> message) throws MessagingException {
            ErrorMessage em = (ErrorMessage) message;
            String errorMessage = em.getPayload().getMessage();

            // log it

            throw (MessagingException) em.getPayload();
        }
    };
}

, , , defaultReplyTimeout=0 ( null ).

@Bean
@ServiceActivator(inputChannel="myErrorChannel")
public MessageHandler loggingHandler() {
    LoggingHandler loggingHandler = new LoggingHandler("ERROR");
    loggingHandler.setExpression("payload.message");
    return loggingHandler;
}

( ).

+2

All Articles