[英]Print exception stacktrace in Apache Camel
我正在使用 Spring Boot 和 Apache Camel 開發一個程序,該程序使用 FTP 從文件服務器讀取文件並使用 FTP 將其寫入另一個文件服務器。 我正在 JBoss EAP 服務器中部署 Spring Boot 應用程序。 當我使用Apache commons-net 庫連接到FTP 服務器時,它失敗了,異常,無法連接到FTP 服務器。 我打印了堆棧跟蹤。 例外情況如下:
<<Some FTP logs before connecting>>
500 - I won't open a connection to IP.
java.lang.NullPointerException
...
...
但是當我使用 Apache Camel 做同樣的事情時,它不會打印任何異常消息或堆棧跟蹤或 FTP 日志。 下面是我的程序:
public void configure() throws Exception {
errorHandler(defaultErrorHandler()
.maximumRedeliveries(3)
.redeliveryDelay(1000)
.retryAttemptedLogLevel(LoggingLevel.WARN));
from("direct:transferFile")
.log("Transferring file")
.process(requestProcessor)
.pollEnrich()
.simple("${exchangeProperty.inputEndpoint}").timeout(0).aggregationStrategy(requestAggregator)
.choice()
.when(body().isNotNull())
.toD("${exchangeProperty.outputEndpoint}", true)
.log("File transferred")
.otherwise()
.log("Empty body, exiting");
}
誰能建議我如何在 Apache Camel 中打印堆棧跟蹤和 FTP 日志?
為什么不將onException子句與您的特定選項一起使用:
onException(NullPointerException.class)
.maximumRedeliveries(3)
.redeliveryDelay(1000)
.retryAttemptedLogLevel(LoggingLevel.WARN);
對於日志記錄,使用帶有更多參數的 log() 來顯示這些消息。
.log(LoggingLevel.WARN,"Transferring file ${body}")
也許您的日志由於您的日志級別而未顯示。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.