10-17-2023 02:30 PM
Hello,
I would like to know if there is a way to change where the .log file generated by the API is stored. I want this in a /logs/ dir, not in the current directory where my script lives.
I don't want to suppress the log, nor do I want to manually or programmatically move it.
Solved! Go to Solution.
10-18-2023 01:28 AM
Hello,
dashboard = meraki.DashboardAPI(output_log=True, print_console=False, log_path='/logs/')
# output_log (boolean): create an output log file?
# log_path (string): path to output log; by default, working directory of script if not specified
# print_console (boolean): print logging output to console?
This configuration ensures that the log files generated by the API will be stored in the '/logs/' directory.
Let me knew if this resolve you issue?
10-17-2023 06:43 PM
Untested, but try configuring output_log.
https://github.com/meraki/dashboard-api-python/blob/main/meraki/__init__.py#L79
Untested (plan B), but right before (or maybe right afterwards) initialising the class, try adding:
import logging
...
logging.getLogger('meraki').addHandler(logging.FileHandler(f'cpmr_log_{datetime.datetime.now():%Y-%m-%d_%H-%M-%S}.log'))
10-18-2023 12:30 PM
I basically am implementing this already. I've overridden the log, actually its pretty neat because using python logging, I can simply create a log where I want it and log away my info, warnings and errors for my script, but because I'm using the meraki module in the same runtime, all the meraki logs automatically are written in my new log within /logs.
That said, the meraki api still creates the log file in the other dir, but it's blank.
10-18-2023 01:28 AM
Hello,
dashboard = meraki.DashboardAPI(output_log=True, print_console=False, log_path='/logs/')
# output_log (boolean): create an output log file?
# log_path (string): path to output log; by default, working directory of script if not specified
# print_console (boolean): print logging output to console?
This configuration ensures that the log files generated by the API will be stored in the '/logs/' directory.
Let me knew if this resolve you issue?
10-18-2023 01:41 PM
Worked! Thanks 🙂
I had to declare the path as './logs/'
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