繁体   English   中英

在 Apache Camel 中打印异常堆栈跟踪

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM