How to use Paramiko logging?

Jason007 picture Jason007 · Dec 21, 2014 · Viewed 23.5k times · Source

I'm using Paramiko in Python to run command on a box through SSH. How to use Paramiko logging? I mean force it to make logs (in a file or terminal) and set the log level.

Answer

Burhan Khalid picture Burhan Khalid · Dec 21, 2014

Paramiko names its loggers, so simply:

import logging
import paramiko

logging.basicConfig()
logging.getLogger("paramiko").setLevel(logging.WARNING) # for example

See the logging cookbook for some more examples.

You can also use log_to_file from paramiko.util to log directly to a file.