Limit jsch output in Spring integration

I am trying to limit the output of the com.jcraft.jsch package in my Spring Boot application. My application uses Spring Intgration and has log4j.properties files defining the following log levels

# Root logger option
log4j.rootLogger=DEBUG
log4j.category.com.jcraft.jsch=ERROR
log4j.category.org.springframework.integration.file=ERROR

      

And yet I am getting a lot of messages with INFO levels from this package ... I expected it to filter it out. I followed the short description at the bottom link

Anyone who has any idea why I'm still awash with comm. detail from jsch?

2015-05-21 11:12:55.750  INFO 10684 --- [ask-scheduler-1] com.jcraft.jsch                          : aes256-cbc is not available.
2015-05-21 11:12:55.750  INFO 10684 --- [ask-scheduler-1] com.jcraft.jsch                          : aes192-cbc is not available.
2015-05-21 11:12:55.750  INFO 10684 --- [ask-scheduler-1] com.jcraft.jsch                          : CheckKexes: diffie-hellman-group14-sha1
2015-05-21 11:12:55.770  INFO 10684 --- [ask-scheduler-1] com.jcraft.jsch                          : SSH_MSG_KEXINIT sent
2015-05-21 11:12:55.770  INFO 10684 --- [ask-scheduler-1] com.jcraft.jsch                          : SSH_MSG_KEXINIT received

      

I am using log4j.1.2.17 and slf4j and my log4j.properties is under src.main.resources

+3


source to share


4 answers


Answering my question, I had to do the following:



  • Exclude classic log from my boot starter. Since this Spring Boot relies on Apache registration and login. In gradle it looks like this:

    compile("org.springframework.boot:spring-boot-starter-integration") { exclude module: "logback-classic" }

  • Add dependency on my boolean choice, log4j:

    compile("org.springframework.boot:spring-boot-starter-log4j")

  • Create a log4j.properies file inside src / main / java / resources / where I state the jsch log shoud level should be set to warning. log4j.category.com.jcraft.jsch = WARN

    log4j.debug=true log4j.rootLogger=info, stdout, file log4j.category.com.jcraft.jsch=WARN log4j.category.org.springframework.integration.file=info

    log4j.appender.stdout = org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target = System.out log4j.appender.stdout.layout = org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern =% d {yyyy-MM-dd HH: mm: ss}% -5p% c {1}:% L -% m% n

    log4j.appender.file = org.apache.log4j.RollingFileAppender log4j.appender.file.File = C: \ log4j-application.log log4j.appender.file.MaxFileSize = 5MB log4j.appender.file.MaxBackupIndex = 10 log4j.appender .file.layout = org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern =% d {yyyy-MM-dd HH: mm: ss}% -5p% c {1}:% L -% m % n

+2


source


You may have chosen a different configuration in the classpath.



Run with -Dlog4j.debug=true

to see which file is being used (and how the levels are set for each category.

0


source


It seems that including log4j.category.com.jcraft.jsch=DEBUG

(also ERROR, FATAL) as the manual pointed out does not change the verbosity of the jsch log.

Also SftpMessageHandler.setLogging(false)

does not disable verbose jsch logging.

0


source


You can just add logging.level.com.jcraft.jsch=WARN

to your application.properties

. See https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-logging.html#boot-features-custom-log-levels .

0


source







All Articles