Код: Выделить всё
logging.basicConfig(
filename="script_log.log",
encoding="utf-8",
filemode="a",
format="{asctime} - {levelname} - {message}",
style="{",
datefmt="%Y-%m-%d %H:%M",
)
Код: Выделить всё
def getCertList(ip_address, username, password, file_path,prompt='admin:'):
# Connect to Server
try:
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect(hostname=ip_address, username=username, password=password, look_for_keys=False,
allow_agent=False, timeout=30)
interact = SSHClientInteraction(ssh_client, timeout=360,
display=False) # "display=True" is just to show you what script does in real time. While in production you can set it to False
interact.expect(prompt)
except:
logging.warning(f"Unable to connect to server {ip_address}, check network connectivity please.", exc_info=True)
Код: Выделить всё
logging.info("All Information has been collected sucessfully. ")
Я попробовал использовать open, чтобы открыть файл script_log.log и записать строку, это сработало, поэтому должна быть проблема с logging.info, но я не смог понять.
Подробнее здесь: https://stackoverflow.com/questions/792 ... e-log-file
Мобильная версия