Spring boot Apache Camel不打印FTP日志

Spring boot Apache Camel不打印FTP日志,spring-boot,java-8,apache-camel,Spring Boot,Java 8,Apache Camel,我在ApacheCamel中有一条路由,我正在从Spring启动应用程序调用它。我的驼峰路由使用FTP从一台服务器拾取文件,并使用FTP传输到另一台服务器。我的路线如下所示: public void configure() throws Exception { errorHandler(defaultErrorHandler() .maximumRedeliveries(3) .redeliveryDelay(100

我在ApacheCamel中有一条路由,我正在从Spring启动应用程序调用它。我的驼峰路由使用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

您能告诉我需要在哪个文件中添加这些条目吗?在您的资源文件夹中创建log4j2.properties并用示例填充它。当您运行camel:run或springboot:run时,您必须看到来自ftp组件的额外信息。