rbeckman-nextgen / test-mc

test-migration
1 stars 0 forks source link

Add better logging for file connectors #3555

Open rbeckman-nextgen opened 4 years ago

rbeckman-nextgen commented 4 years ago

Many people have asked about this or something similar / related:

[http://www.mirthcorp.com/community/forums/showthread.php?t=12977] [http://www.mirthcorp.com/community/forums/showthread.php?t=12979] [http://www.mirthcorp.com/community/forums/showthread.php?t=7072] [http://www.mirthcorp.com/community/forums/showthread.php?t=9940]

To take SFTP as an example, JSch has an option to set a logger, but by default it doesn't log anything out. So when you need to figure out why a connection isn't working from the client side, it's hard to do.

Our FTP library is a bit better because we do some of our own logging in FtpConnection, but FTPClient also has a addProtocolCommandListener method that we're not tapping into.

Imported Issue. Original Details: Reporter: narupley Created: 2015-02-12T11:18:57.000-0800

rbeckman-nextgen commented 4 years ago

As a workaround for those of you who want to enable logging for JSch, you can do it manually in a global deploy script: \ \ {code}com.jcraft.jsch.JSch.setLogger(new com.jcraft.jsch.Logger({ isEnabled: function(level) { var logger = org.apache.log4j.Logger.getLogger('JSch');

    switch (level) {
        case com.jcraft.jsch.Logger.DEBUG:
            return logger.isEnabledFor(org.apache.log4j.Level.DEBUG);
        case com.jcraft.jsch.Logger.INFO:
            return logger.isEnabledFor(org.apache.log4j.Level.INFO);
        case com.jcraft.jsch.Logger.WARN:
            return logger.isEnabledFor(org.apache.log4j.Level.WARN);
        case com.jcraft.jsch.Logger.ERROR:
            return logger.isEnabledFor(org.apache.log4j.Level.ERROR);
        case com.jcraft.jsch.Logger.FATAL:
            return logger.isEnabledFor(org.apache.log4j.Level.FATAL);
    }
},

log: function(level, message) {
    var logger = org.apache.log4j.Logger.getLogger('JSch');

    switch (level) {
        case com.jcraft.jsch.Logger.DEBUG:
            logger.debug(message);
            break;
        case com.jcraft.jsch.Logger.INFO:
            logger.info(message);
            break;
        case com.jcraft.jsch.Logger.WARN:
            logger.warn(message);
            break;
        case com.jcraft.jsch.Logger.ERROR:
            logger.error(message);
            break;
        case com.jcraft.jsch.Logger.FATAL:
            logger.fatal(message);
            break;
    }
}

}));{code} \ Then you just have to turn up logging in your log4j.properties file: \ \ {code}log4j.logger.JSch = DEBUG{code}

Imported Comment. Original Details: Author: narupley Created: 2015-02-12T12:08:14.000-0800