Syslog handler for logging module. Forget print statements, send to a centralized syslog server instead. #17810
DavesCodeMusings
started this conversation in
Show and tell
Replies: 3 comments 1 reply
-
That's neat, thanks for sharing! |
Beta Was this translation helpful? Give feedback.
0 replies
-
This is really useful - thanks for sharing! |
Beta Was this translation helpful? Give feedback.
0 replies
-
Im pleasantly surprised that you are able to add a logging handler on MicroPython. For some reason i assumed that was not possible. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Using the MicroPython logging module and coding examples, along with a little help from the Python logging handlers source code, I was able to create a MicroPython custom handler class for sending log messages to a network-based syslog server. You can find it on my GitHub page:
https://github.com/DavesCodeMusings/SyslogHandler-MicroPython
In a nutshell, you need a network attached MicroPython device and the IP address and port of a syslog server on your network. Using MicroPython's
logging.getLogger().addHandler()
method, you create another destination for your log messages. They'll still print to the console, just like they would with a regular logging setup, but you'll also get a copy sent to your syslog server.For example, on the console:
And in the syslog server's log file:
You can get it installed with mip.
A sample main.py shows how to get it set up from there.
Have fun logging everything on the planet!
Beta Was this translation helpful? Give feedback.
All reactions