繁体   English   中英

Apache Camel 不打印 FTP 日志

[英]Apache Camel not printing FTP logs

我在 Apache Camel 中有一条从 Spring Boot 应用程序调用的路由。 我的 Camel 路由使用 FTP 从一台服务器获取文件,然后使用 FTP 传输到另一台服务器。 我的路线如下所示:

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();
    }

问题是当它尝试连接到 FTP 服务器时,它没有打印 FTP 日志,如用户名、密码等。 谁能告诉我如何启用 FTP 日志?

只需为“org.apache.camel.component.file.remote”包启用跟踪级别。 这里的 log4j2 示例:

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

输出:

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://anonymous@10.192.0.50: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://anonymous@10.192.0.50: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://anonymous@10.192.0.50: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://anonymous@10.192.0.50: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://anonymous@10.192.0.50: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://anonymous@10.192.0.50: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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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