09-04-2025 08:19 AM
Hello,
Everytime the pyats connection gets executed, it creates a log file ([device]-cli-[timestamp].log in the script directory.
I cannot seem to disable it
I am running 25.7 version
# Attempt to connect to the device try: LOGGER.info(f">>> Connecting to {device_name}...") device.connect(log_stdout=False) assert device.connected, f"Failed to connect to device {device_name}" LOGGER.info(f"Successfully connected to {device_name}\n") return device except (TimeoutError, StateMachineError, ConnectionError) as e: LOGGER.error(f"Failed to connect to {device_name}: {e}\n") return None
09-04-2025 08:42 AM
The log_stdout=False only disables stdout logging, not the CLI log files. You can disable this a few ways, via the connection params in yiour script, in your yaml test bed. You can also disable this globally with somethiong like
import os
os.environ['PYATS_LOGS_DIR'] = '/dev/null'
Maybe look at the first two options in the params or yaml.
09-04-2025 08:56 AM - edited 09-04-2025 08:57 AM
@bigevilbeard
There should be a better way of doing it rather than:
os.environ['PYATS_LOGS_DIR'] = '/dev/null'
I read the following documentation and could not find out where in the parameters or yaml file we can disable it
Connection Basics — Unicon Documentation
There is a LOGGING section, but it only shows how to redirect the log file
Thanks
09-04-2025 09:11 AM
Yes that is brute force method. So maybe the other options are no longer supported? Can you try adjusting the logging level of the pyats connections handler, try, something like ..
from pyats.connections import log
for handler in log.handlers:
if isinstance(handler, logging.FileHandler):
handler.setLevel(logging.CRITICAL)
#Your code below
09-08-2025 09:01 AM - edited 09-08-2025 09:01 AM
@bigevilbeard
That did not work, as I got an error message
There were no specific about the error, just failed
BTW, this started happening after upgrading to the latest code 25.7
So they must have changed something in the code
09-08-2025 09:47 AM
Odd. I don’t see anything in the change log https://pubhub.devnetcloud.com/media/unicon/docs/changelog/2025/july.html
I would open an issue on the repo for this version. It would be odd to have an undocumented change.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide