Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No handlers could be found for logger paramiko

Tags:

python

I am using paramiko module for ssh connection.I am facing below problem:

No handlers could be found for logger I am not getting the reason of this problem.I tried to get solution from below link but not able to get reason. No handlers could be found for logger "paramiko.transport"

I am using below code:

           1.ssh = paramiko.SSHClient()
       2.ssh.set_missing_host_key_policy(
       3.paramiko.AutoAddPolicy())

       4.ssh.connect(serverip, username=username, 
       5.password=password,timeout=None)
       6.transport = ssh.get_transport()
       7.transport.set_keepalive(30)

       8.stdin, stdout, stderr =ssh.exec_command(cmd)
       9.tables=stdout.readlines()
       10.ssh.close()

I think i am getting this problem at line no 8.Please advice how can i solve this.

like image 492
rahul Avatar asked Oct 03 '13 06:10

rahul


2 Answers

I found the solution from this website.

Basically, you just need to add a line:

paramiko.util.log_to_file("filename.log")

Then all connection will be logged to the file.

like image 90
Sharuzzaman Ahmat Raslan Avatar answered Nov 16 '22 10:11

Sharuzzaman Ahmat Raslan


cf http://docs.python.org/2.7/howto/logging.html#what-happens-if-no-configuration-is-provided

To make a long story short: Paramiko uses the logging package and do it the RightWay - which for a library package or module is to not assume anything about the execution context and let the application take care of logging configuration. You have not configured any logger so you get this message. The obvious solution is configure the logging according to your needs.

like image 36
bruno desthuilliers Avatar answered Nov 16 '22 09:11

bruno desthuilliers