javaloggingsshsshj

how can I modify net.schmizz.sshj logging level?


Can I change the level of logger for the default config or disable it for sshj library my code so far [

Config config = new DefaultConfig();
config.setKeepAliveProvider(KeepAliveProvider.KEEP_ALIVE);
SSHClient sshClient = new SSHClient(config);

and when I try the above code I have these problems :

[main] WARN net.schmizz.sshj.DefaultConfig - Illegal key size
[main] WARN net.schmizz.sshj.DefaultConfig - Illegal key size
[main] WARN net.schmizz.sshj.DefaultConfig - Illegal key size
[main] WARN net.schmizz.sshj.DefaultConfig - Illegal key size
[main] WARN net.schmizz.sshj.DefaultConfig - Illegal key size
[main] WARN net.schmizz.sshj.DefaultConfig - No such algorithm: IDEA/CBC/NoPadding
[main] WARN net.schmizz.sshj.DefaultConfig - No such algorithm: IDEA/CTR/NoPadding
[main] WARN net.schmizz.sshj.DefaultConfig - Illegal key size
[main] WARN net.schmizz.sshj.DefaultConfig - Illegal key size
[main] WARN net.schmizz.sshj.DefaultConfig - Illegal key size
[main] WARN net.schmizz.sshj.DefaultConfig - Illegal key size
[main] WARN net.schmizz.sshj.DefaultConfig - Illegal key size
[main] WARN net.schmizz.sshj.DefaultConfig - Illegal key size
[main] WARN net.schmizz.sshj.DefaultConfig - Illegal key size
[main] WARN net.schmizz.sshj.DefaultConfig - Illegal key size
[main] WARN net.schmizz.sshj.DefaultConfig - Illegal key size
[main] WARN net.schmizz.sshj.DefaultConfig - Illegal key size or default parameters
[main] WARN net.schmizz.sshj.DefaultConfig - Disabling high-strength ciphers: cipher strengths apparently limited by JCE policy

Solution

  • SSHJ uses the slf4j logging API. This means that you can configure it with any logging implementation that implements slf4j. Typically this is the logback logger.

    You can configure that by adding a logback.xml file containing for instance the following configuration:

    <configuration>
    
      <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
          <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%.-20thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
      </appender>
    
      <root level="info">
        <appender-ref ref="STDOUT"/>
      </root>
    
      <logger name="net.schmizz.sshj" level="error"/>
    
    </configuration>
    

    BTW the reason you're seeing those messages is that you're running without the unlimited strength cryptography extensions.