Logging in Python Like a Pro

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Scout Monitoring - Free Django app performance insights with Scout Monitoring
Get Scout setup in minutes, and let us sweat the small stuff. A couple lines in settings.py is all you need to start monitoring your apps. Sign up for our free tier today.
www.scoutapm.com
featured
InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
  • python-logging-discord-handler

    Redirect your Python log output to Discord

  • A very good post on creating good log contexts.

    For powerful log channeling and notifications to Telegram, Slack, etc. there is this Python package:

    https://pypi.org/project/notifiers/

    I also created a logging handler for Discord, where one can get notifications on errors to a private channel:

    https://github.com/tradingstrategy-ai/python-logging-discord...

  • A very good post on creating good log contexts.

    For powerful log channeling and notifications to Telegram, Slack, etc. there is this Python package:

    https://pypi.org/project/notifiers/

    I also created a logging handler for Discord, where one can get notifications on errors to a private channel:

    https://github.com/tradingstrategy-ai/python-logging-discord...

  • Scout Monitoring

    Free Django app performance insights with Scout Monitoring. Get Scout setup in minutes, and let us sweat the small stuff. A couple lines in settings.py is all you need to start monitoring your apps. Sign up for our free tier today.

    Scout Monitoring logo
  • awslogs

    AWS CloudWatch logs for Humans™

  • Using the official CLI (aws logs get-log-events) or https://github.com/jorgebastida/awslogs is pretty close to SSH-ing and grepping.

  • vector

    A high-performance observability data pipeline.

  • Honestly, I like to keep the logger as decoupled and minimalist as possible. There’s https://vector.dev which can basically ship your logs from source A to destination B. Separation of concerns makes things much more easier.

  • logma

    structlog defaults for machines not for humans

  • You always need some boilerplate to get structlog working. I always use this (author) to have the needed defaults https://github.com/peakiq/logma.

  • python-logfmter

    Using the stdlib logging module and without changing a single logging call, logfmter supports global (first and third party) logfmt structured logging.

  • https://github.com/jteppinette/python-logfmter

    I made this library to make global structured logging in Python super easy.

  • django-guid

    Inject an ID into every log message from a Django request. ASGI compatible, integrates with Sentry, and works with Celery

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • asgi-correlation-id

    Request ID propagation for ASGI apps

  • Loguru

    Python logging made (stupidly) simple

  • You should try the loguru library. I was able to roll a rolling-upload-to-s3 adapter in under an hour. Switching to json logs is one bool flag away. Plus it's gorgeous

    https://github.com/Delgan/loguru

    Also iirc s3's "file-like interface" does not actually obey the file protocol, which is obnoxious.

  • pygogo

    A Python logging library with superpowers

  • I'd just like to plug my lib, pygogo (https://github.com/reubano/pygogo). Here's a structured log example taken from the docs.

      import pygogo as gogo

  • bracelogger

    A Python library that enables using the brace-style string formatting in log messages

  • As there are real advantages to providing a template and object args separately, this is a bit of a shame since it pushes people to use pre-formatted strings without any args instead.

    I fixed this for myself by writing bracelogger[0]. If this is a pain point for you too, you might find it useful.

    [0]: https://github.com/pR0Ps/bracelogger

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Build and Deploy a URL Shortener using Django REST Framework and Managed Postgres

    2 projects | dev.to | 12 Dec 2023
  • Loguru VS polog - a user suggested alternative

    2 projects | 9 Dec 2023
  • Resource for Django's internal structure

    3 projects | /r/djangolearning | 25 Jun 2023
  • a few comments and questions about loguru - the most popular 3rd party logging module for Python

    2 projects | /r/Python | 18 Apr 2023
  • Open Source Django Projects for Study

    9 projects | /r/django | 17 Jan 2023