如何停止骆驼 sftp 消费者的 JSCH 日志

How to stop JSCH logs for camel sftp consumer

我的骆驼 SFTP 消费者每 10 秒连接一次服务器,并且在每次连接期间它都会打印大量日志消息,如此处所述。

02-05-2016 20:48:34,441 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> kex: client: hmac-md5,hmac-sha1,hmac-sha1-96,hmac-md5-96

02-05-2016 20:48:34,441 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> kex: client: none

02-05-2016 20:48:34,441 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> kex: client: none

02-05-2016 20:48:34,441 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> kex: client:

02-05-2016 20:48:34,441 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> kex: client:

02-05-2016 20:48:34,441 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> kex: server->client aes128-ctr hmac-md5 none

02-05-2016 20:48:34,441 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> kex: client->server aes128-ctr hmac-md5 none

02-05-2016 20:48:34,443 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> SSH_MSG_KEXDH_INIT sent

02-05-2016 20:48:34,444 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> expecting SSH_MSG_KEXDH_REPLY

02-05-2016 20:48:34,762 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> ssh_rsa_verify: signature true

02-05-2016 20:48:34,762 WARN (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> Permanently added '11.11.11.11' (RSA) to the list of known hosts.

02-05-2016 20:48:34,763 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> SSH_MSG_NEWKEYS sent

02-05-2016 20:48:34,763 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> SSH_MSG_NEWKEYS received

02-05-2016 20:48:34,763 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> SSH_MSG_SERVICE_REQUEST sent

02-05-2016 20:48:35,079 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> SSH_MSG_SERVICE_ACCEPT received

02-05-2016 20:48:35,391 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> Authentications that can continue: publickey,keyboard-interactive,password

02-05-2016 20:48:35,391 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> Next authentication method: publickey

02-05-2016 20:48:35,391 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> Authentications that can continue: password

02-05-2016 20:48:35,391 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> Next authentication method: password

02-05-2016 20:48:35,707 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> Authentication succeeded (password).

02-05-2016 20:48:36,662 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] Connected to sftp://username@11.11.11.11:22

02-05-2016 20:48:36,662 INFO (org.apache.camel.component.file.remote.SftpConsumer) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] Connected and logged in to: sftp://username@11.11.11.11:22

02-05-2016 20:48:38,539 INFO (org.apache.camel.component.file.remote.SftpOperations) [Camel (camel-99) thread #117 - sftp://username:******@11.11.11.11:22/download] JSCH -> Disconnecting from 11.11.11.11 port 22

如何阻止这些消息出现在日志中?

如果您使用的是像 log4j 这样的记录器,您只需在记录器配置中使用以下行关闭 JSCH 记录:

log4j.logger.org.apache.camel.component.file.remote.SftpOperations = OFF

作为更改记录器配置的替代方法,当前的 Camel sFTP documentation 提到了您可以在端点上设置的几个选项:

  • jschLoggingLevel
  • readLockLoggingLevel
  • runLoggingLevel

例如你可以设置:

sftp://user@myserver.mydomain.net:9921/path/to/folder?binary=true&jschLoggingLevel=WARN&readLockLoggingLevel=INFO&runLoggingLevel=WARN

您可以直接在端点中调整每个类别以满足您的需求,而无需更改记录器的配置。