Home » Java » java – Print exception stacktrace in Apache Camel-Exceptionshub

java – Print exception stacktrace in Apache Camel-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment


I am developing a program using Spring Boot and Apache Camel that reads a file from a file server using FTP and writes it to another file server using FTP. I am deploying the Spring Boot application in JBoss EAP server. when I used Apache commons-net library to connect to the FTP server, it failed with an exception, it was unable to connect to the FTP server. I printed the stacktrace. The exception is as below:

    <<Some FTP logs before connecting>>
    500 - I won't open a connection to IP.

But when I am doing the same thing using Apache Camel, It is not printing any exception message or stacktrace or the FTP logs. Below is my program:

public void configure() throws Exception {

            .log("Transferring file")
                    .toD("${exchangeProperty.outputEndpoint}", true)
                    .log("File transferred")
                    .log("Empty body, exiting");

Can anyone please suggest me how will I print the stack trace and FTP logs in Apache Camel?

How to&Answers:

Why not use onException clause with your specific options :


For logging use log() with more parameters to display those messages.

.log(LoggingLevel.WARN,"Transferring file ${body}")

Maybe your logs doesn’t display because of your log level.