How to temporarily disable logging to nornir.log #748
-
Hi, I have been using Nornir to transfer files via SCP to switches, and all has been going well except for one caveat. During the SCP command on the switches, it asks for a password which when passed, shows up in the nornir.log file as plaintext. For obvious security reasons, I would like to turn off the logging function when I pass the password to the switch, but still keep logging functional otherwise. Currently, my SCP code looks like this:
The above code works perfectly fine, and I have tried adding Ideally, my code would look something like this when working:
Is there some way to turn off logging for a few tasks and then resume logging after a certain point in Nornir without reinitializing a new Nornir object? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@DarkSplash there is a way by turning off a specific logger that emits a message. Could you show the log message you want to suppress (obviously remove sensitive information yourself)?
However, it might worth having a discussion and ask underling library maintainers to remove sensitive information from logs by default? Not sure. |
Beta Was this translation helpful? Give feedback.
-
Isn't the issue due to Nornir logging the arguments in the Nornir .run() call? So whatever Netmiko, NAPALM, Scrapli does here would not be relevant (i.e. the logging would have happened before then)? Another workaround is to make a custom Nornir task and not pass any arguments with sensitive information so that nr.run() logging of arguments would not be relevant. You can always bind information to the Nornir host object and access it inside the Nornir custom task. In other words, you should be able to avoid needing to pass sensitive information like passwords via argument calls (that get logged). |
Beta Was this translation helpful? Give feedback.
@DarkSplash there is a way by turning off a specific logger that emits a message. Could you show the log message you want to suppress (obviously remove sensitive information yourself)?
generally it would look like this:
However, it might worth having a discussion and ask underling library maintainers to remove sensitive information from logs by default? Not sure.