Meraki Log Location

Solved
ToryDav
Building a reputation

Meraki Log Location

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.

1 Accepted Solution
Badr-eddine
Getting noticed

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?

View solution in original post

4 Replies 4
PhilipDAth
Kind of a big deal
Kind of a big deal

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'))

 

 

ToryDav
Building a reputation

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.

Badr-eddine
Getting noticed

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?

ToryDav
Building a reputation

Worked! Thanks 🙂

I had to declare the path as './logs/' 

Get notified when there are additional replies to this discussion.