0
votes

I have a route in Apache Camel that I am calling from a Spring Boot application. My Camel route picks up a file from one server using FTP and transfers to another server using FTP. My route looks like the below:

public void configure() throws Exception {
        errorHandler(defaultErrorHandler()
                .maximumRedeliveries(3)
                .redeliveryDelay(1000)
                .loggingLevel(LoggingLevel.DEBUG)
                .retryAttemptedLogLevel(LoggingLevel.DEBUG));

        from("direct:transferFile")
            .doTry()
                .log("Transferring file")
                .process(requestProcessor)
                .log("${exchangeProperty.inputEndpoint}")
                .pollEnrich()
                    .simple("${exchangeProperty.inputEndpoint}").timeout(0).aggregationStrategy(requestAggregator)
                .choice()
                    .when(body().isNotNull())
                        .toD("${exchangeProperty.outputEndpoint}", true)
                        .log("File transferred")
                        .endChoice()
                    .otherwise()
                        .log("Empty body, exiting")
                        .endChoice()
                .endDoTry()
            .doCatch(Exception.class)
                .log("Exception")
            .end();
    }

The problem is it is not printing the FTP logs like username, password etc when it is attempting to connect to the FTP servers. Can anyone please let me know how can I enable the FTP logs?

1

1 Answers

1
votes

Just enable TRACE level for "org.apache.camel.component.file.remote" package. Here log4j2 example:

appender.stdout.type = Console
appender.stdout.name = stdout
appender.stdout.layout.type = PatternLayout
appender.stdout.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
rootLogger.level = INFO
rootLogger.appenderRef.stdout.ref = stdout

logger.stdout.name = org.apache.camel.component.file.remote
logger.stdout.level = TRACE

Output:

2020-02-20 12:57:49,355 [ing.Main.main()] DEBUG FtpEndpoint                    - Created FTPClient [connectTimeout: 10000, soTimeout: 300000, dataTimeout: 30000, bufferSize: 32768, receiveDataSocketBufferSize: 0, sendDataSocketBufferSize: 0]: org.apache.commons.net.ftp.FTPClient@2620b111
2020-02-20 12:57:49,400 [ing.Main.main()] DEBUG RemoteFileProducer             - Starting
2020-02-20 12:57:49,401 [ing.Main.main()] TRACE RemoteFileProducer             - Starting producer: RemoteFileProducer[ftp://[email protected]:21/Public/someFolder/]
2020-02-20 12:57:49,402 [ing.Main.main()] INFO  SpringCamelContext             - Route: timer:foo?period=5s started and consuming from: timer://foo?period=5s
2020-02-20 12:57:49,403 [ing.Main.main()] INFO  SpringCamelContext             - Total 1 routes, of which 1 are started
2020-02-20 12:57:49,404 [ing.Main.main()] INFO  SpringCamelContext             - Apache Camel 2.25.0 (CamelContext: Test) started in 0.358 seconds
2020-02-20 12:57:50,426 [2 - timer://foo] TRACE RemoteFileProducer             - Processing file: Public/someFolder/test.txt for exchange: Exchange[ID-Antons-iMac-local-1582189068946-0-1]
2020-02-20 12:57:50,426 [2 - timer://foo] DEBUG RemoteFileProducer             - Not already connected/logged in. Connecting to: ftp://[email protected]:21/Public/someFolder/
2020-02-20 12:57:50,426 [2 - timer://foo] TRACE FtpOperations                  - Connecting using FTPClient: org.apache.commons.net.ftp.FTPClient@2620b111
2020-02-20 12:57:50,427 [2 - timer://foo] TRACE FtpOperations                  - Connecting to ftp://[email protected]:21 using connection timeout: 10000
2020-02-20 12:57:52,461 [2 - timer://foo] TRACE FtpOperations                  - Using SoTimeout=300000
2020-02-20 12:57:52,462 [2 - timer://foo] TRACE FtpOperations                  - Attempting to login user: anonymous using password: ********
2020-02-20 12:57:59,903 [2 - timer://foo] TRACE FtpOperations                  - User anonymous logged in: true
2020-02-20 12:57:59,926 [2 - timer://foo] DEBUG RemoteFileProducer             - Connected and logged in to: ftp://[email protected]:21/Public/someFolder/
2020-02-20 12:57:59,926 [2 - timer://foo] TRACE FtpOperations                  - buildDirectory(Public/someFolder)
2020-02-20 12:58:00,020 [2 - timer://foo] TRACE FtpOperations                  - changeCurrentDirectory(/)
2020-02-20 12:58:00,020 [2 - timer://foo] TRACE FtpOperations                  - Changing directory: /
2020-02-20 12:58:00,122 [2 - timer://foo] TRACE RemoteFileProducer             - About to write [Public/someFolder/test.txt] to [ftp://[email protected]:21/Public/someFolder/] from exchange [Exchange[ID-Antons-iMac-local-1582189068946-0-1]]
2020-02-20 12:58:00,122 [2 - timer://foo] DEBUG FtpClientActivityListener      - Uploading to host: ftp://[email protected]:21 file: Public/someFolder/test.txt starting
2020-02-20 12:58:00,122 [2 - timer://foo] TRACE FtpOperations                  - storeFile(Public/someFolder/test.txt)
2020-02-20 12:58:00,122 [2 - timer://foo] TRACE FtpOperations                  - getCurrentDirectory()
2020-02-20 12:58:00,212 [2 - timer://foo] TRACE FtpOperations                  - Current dir: /
2020-02-20 12:58:00,212 [2 - timer://foo] TRACE FtpOperations                  - changeCurrentDirectory(Public/someFolder)
2020-02-20 12:58:00,212 [2 - timer://foo] TRACE FtpOperations                  - Changing directory: Public
2020-02-20 12:58:00,217 [2 - timer://foo] TRACE FtpOperations                  - Changing directory: someFolder
2020-02-20 12:58:00,310 [2 - timer://foo] TRACE FtpOperations                  - doStoreFile(test.txt)
2020-02-20 12:58:00,311 [2 - timer://foo] DEBUG FtpOperations                  - About to store file: test.txt using stream: java.io.ByteArrayInputStream@7eeeaf66
2020-02-20 12:58:00,311 [2 - timer://foo] TRACE FtpOperations                  - Client storeFile: test.txt
2020-02-20 12:58:00,527 [2 - timer://foo] DEBUG FtpOperations                  - Took 0.216 seconds (216 millis) to store file: test.txt and FTP client returned: true