Arunan Sugunakumar created VFS-864:
--------------------------------------

             Summary: SftpClientFactory.JSchLogger.isEnabled() maps JSch WARN 
level to isDebugEnabled(), so JSch warnings are dropped unless DEBUG is enabled
                 Key: VFS-864
                 URL: https://issues.apache.org/jira/browse/VFS-864
             Project: Commons VFS
          Issue Type: Bug
    Affects Versions: 2.10.0, 2.9.0, 2.8.0
            Reporter: Arunan Sugunakumar


The JSch-to-Commons-Logging bridge in {{SftpClientFactory.JSchLogger}} checks 
the DEBUG level when JSch asks whether WARN is enabled:
{code:java}
@Override
public boolean isEnabled(final int level) {
    switch (level) {
    case FATAL:
        return LOG.isFatalEnabled();
    case ERROR:
        return LOG.isErrorEnabled();
    case WARN:
        return LOG.isDebugEnabled();  
    case DEBUG:
        return LOG.isDebugEnabled();
    case INFO:
        return LOG.isInfoEnabled();
    default:
        return LOG.isDebugEnabled();
    }
}
{code}
The matching {{log()}} method correctly calls {{LOG.warn(msg)}} for 
{{{}WARN{}}}. However, JSch calls {{isEnabled(level)}} before it calls 
{{{}log(level, msg){}}}. So with the logger for 
{{org.apache.commons.vfs2.provider.sftp.SftpClientFactory}} set to WARN or 
INFO, the WARN check fails and JSch warnings are dropped. They are only emitted 
when DEBUG is enabled.

Was mapping WARN to {{isDebugEnabled()}} intentional? 



[https://github.com/apache/commons-vfs/blob/master/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java#L60]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to