Spring Integration logging error channel (slf4j + logback) -
i using spring integration configuration:
@bean messagechannel errorchannel(){ return new publishsubscribechannel(); } @messaginggateway(name = "gatewayinbound", defaultrequestchannel="farsrequestchannel", errorchannel="errorchannel"){ }
with configuration, avoiding showing messages want create basic log such logger.error().
additionally, working slfj , logbak. thus, perfect scenario integrate error message similar configuration in logback xml. reason:
- can use logback log spring integration errorchannel logs?
- can show error sent errorchannel?
can personalize error similar expression in logback? if use, logginghandler, see complete stack trace , want customize message.
[%-5level] - %d{dd/mm/yyyy hh:mm:ss} - [%file:%line] - %msg%n
@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 throw (messagingexception) em.getpayload(); } }; }
if don't want exception propagated, can consume it, need set defaultreplytimeout=0
on gateway (and null
returned).
or
@bean @serviceactivator(inputchannel="myerrorchannel") public messagehandler logginghandler() { logginghandler logginghandler = new logginghandler("error"); logginghandler.setexpression("payload.message"); return logginghandler; }
(the error consumed in case).
Comments
Post a Comment