12-27-2024 05:40 PM - edited 12-27-2024 05:47 PM
Hi,
I am trying to use the "logfile" option in pyats testbed. Unfortunately, the logs are not getting saved.
Has anyone tried this? Any suggestions on how to get this working? Thanks
Sample:
testbed:
name: testbed_file
credentials:
default:
username: 'cisco'
password: 'cisco'
devices:
SWITCH_1:
os: nxos
type: nxos
connections:
cli:
protocol: ssh
ip: 10.10.10.1
arguments:
log_stdout: false
logfile: logfile_1.log
init_config_commands: []
init_exec_commands:
- terminal length 0
PS: I am able to connect to device and run commands.
Thanks in advance!
12-27-2024 07:51 PM
try complete path for the logfile where the program has write permissions.
logfile: ./logs/logfile_1.log # Ensure this path is valid and writable
12-27-2024 09:21 PM
Thanks for the reply @ammahend.
I provided the entire path "/Users/shesh/.../logfile_1.log" But it did not work, still writes to /tmp.
I am saving another file in the same folder from within the code, so I don't think it's an access issue.
12-28-2024 04:03 AM
Update the args section with
arguments: # Remove log_stdout as it's not needed when using logfile logfile: '/path/to/logs/logfile_1.log' # Use absolute path init_config_commands: [] init_exec_commands: - terminal length 0
Ensure you have the correct permissions to write to the location you are attempting. You can create the log directory before running the script, sometimes if this isn’t present the log file will not create and write the file.
01-02-2025 02:08 AM
Thanks @bigevilbeard
I removed the log_stdout (though I don't think it's causing any issue). Still can't get the log file in desired place.
If I directly pass the logfile: '/path/to/logs/logfile_1.log' as a parameter to device.connect, it works. So it's not permission issue.
For some reason logfile from testbed is not getting picked up.
01-02-2025 02:34 AM
As directly passing logfile to device.connect() works, the issue would be in how the testbed configuration is being processed I think.
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