How to use Paramiko logging?
Asked Answered
H

2

24

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.

Helsa answered 21/12, 2014 at 8:7 Comment(0)
I
38

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.

Incommensurate answered 21/12, 2014 at 8:36 Comment(1)
You also need to specify a log file, e.g. paramiko.util.log_to_file("paramiko.log").Lilah
P
11
paramiko.util.log_to_file("<log_file_path>", level = "WARN")
Persson answered 30/8, 2018 at 17:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.