Skip to Content
Python Microservices Development
book

Python Microservices Development

by Tarek Ziadé
July 2017
Beginner to intermediate
340 pages
7h 43m
English
Packt Publishing
Content preview from Python Microservices Development

Sending logs to Graylog

To send logs to Graylog from Python, you can use Graypy (https://github.com/severb/graypy), which converts Python logs to the Graylog Extended Log Format (GELF) (http://docs.graylog.org/en/latest/pages/gelf.html).

Graypy will send the logs via UDP by default, but can also send them via AMQP if you need to be 100% sure that every log makes it to Graylog.

In most cases, UDP is good enough for centralizing logs. But unlike TCP, some packets may be dropped, and you won't know it. If your logging strategy needs more guarantee, a RabbitMQ-based transport will be more reliable.

Plugging graypy consists of using the provided handler in place of one of the built-in handlers:

 handler = graypy.GELFHandler('localhost', 12201) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Microservices Development - Second Edition

Python Microservices Development - Second Edition

Simon Fraser, Tarek Ziadé
Python Web Development with Sanic

Python Web Development with Sanic

Stephen Sadowski, Adam Hopkins

Publisher Resources

ISBN: 9781785881114Supplemental Content