loki-logger-handler
Handler designed for transmitting logs to Grafana Loki in JSON format.
Decision gist · record as of 2026-08-14
Yes, if you are already running Grafana Loki and need a straightforward Python logging integration. The package has no runtime dependencies, low install friction, and a permissive license. However, note that maintenance is aging (last update 2025-05-26, last commit 2026-01-09); if you require active support or plan to use Loki 3.0 structured metadata in production, verify compatibility first or be prepared to maintain a fork.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires a Grafana Loki server endpoint URL, typically provided via environment variable LOKI_URL in the format https://user:password@host/loki/api/v1/push.
- Low install friction with no runtime dependencies.
- Maintenance status is aging—last commit was 2026-01-09 and the package has not been updated since 2025-05-26, so expect slower response to issues or feature requests.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use this package freely in commercial and private projects with minimal restrictions.
last release 2025-05-26 (445 days) · last repo commit 2026-01-09 · 55 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 122,742 downloads/mo, #11,936 on PyPI
Alternatives
Verify before relying
pip install loki-logger-handler
from loki_logger_handler.loki_logger_handler import LokiLoggerHandler
import logging
import os
logger = logging.getLogger("app")
logger.setLevel(logging.DEBUG)
handler = LokiLoggerHandler(
url=os.environ["LOKI_URL"],
labels={"application": "MyApp"},
timeout=10,
)
logger.addHandler(handler)
logger.info("Test message")- Whether loguru integration works reliably with all loguru versions and configurations.
- Performance characteristics when sending high-volume logs or with large batch sizes.
- Compatibility with Loki 3.0 structured metadata features in production environments.
What it is and what it does
loki-logger-handler is a Python logging handler that bridges the standard logging module (and optionally loguru) to Grafana Loki, a log aggregation system. It formats log messages as JSON, attaches custom labels for filtering and querying, and sends them to a Loki server in batches, optionally compressed. The handler automatically includes log metadata like timestamps, process IDs, thread IDs, and function names; you can also attach custom fields via logging extras, which become searchable keys in the JSON payload.
The package supports both Python's built-in logging and the loguru library, with separate formatters for each. It includes options for basic authentication, custom headers, configurable timeouts, and Loki 3.0 structured metadata. Logs are buffered and flushed either when the buffer fills or after a timeout, reducing network overhead. The handler runs as a background thread, so it does not block your application.
Use it for
- Centralize application logs from multiple Python services into a single Loki instance for unified querying and monitoring.
- Add structured metadata (user IDs, trace IDs, request codes) to logs for filtering and correlation in Grafana dashboards.
- Replace file-based logging with cloud-native log aggregation in containerized or serverless deployments.
- Batch and compress logs before sending to reduce network bandwidth and Loki ingestion costs.
- Integrate loguru-based applications with Loki without rewriting logging code.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you are already running Grafana Loki and need a straightforward Python logging integration.
The package has no runtime dependencies, low install friction, and a permissive license. However, note that maintenance is aging (last update 2025-05-26, last commit 2026-01-09); if you require active support or plan to use Loki 3.0 structured metadata in production, verify compatibility first or be prepared to maintain a fork.
Install
loki-logger-handler on PyPI
Before you install
Low install friction with no runtime dependencies. Maintenance status is aging—last commit was 2026-01-09 and the package has not been updated since 2025-05-26, so expect slower response to issues or feature requests.
Requires a Grafana Loki server endpoint URL, typically provided via environment variable LOKI_URL in the format https://user:password@host/loki/api/v1/push.
License in practice
MIT license is permissive; you can use this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install loki-logger-handler
from loki_logger_handler.loki_logger_handler import LokiLoggerHandler
import logging
import os
logger = logging.getLogger("app")
logger.setLevel(logging.DEBUG)
handler = LokiLoggerHandler(
url=os.environ["LOKI_URL"],
labels={"application": "MyApp"},
timeout=10,
)
logger.addHandler(handler)
logger.info("Test message")
Verify before relying
- Whether loguru integration works reliably with all loguru versions and configurations.
- Performance characteristics when sending high-volume logs or with large batch sizes.
- Compatibility with Loki 3.0 structured metadata features in production environments.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=2.7 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Aging 445 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 122,742 / month, #11,936 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9 |
Evidence: loki_logger_handler-1.1.2-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “grafana loki logging handler”
- loki-logger-handlerA logging handler that sends Python log messages to Grafana Loki in…
- python-logging-lokiA Python logging handler that sends log records to Grafana Loki via…
- mcp-grafanaAn MCP server that exposes Grafana dashboards, datasources, and query…
Give your agent the search over MCP, or paste the wish link into any chat.
More Monitoring packages
Wraps any iterable to display a real-time progress bar in the terminal or Jupyter notebook, showing iteration count, elapsed time, and estimated time remaining.
Provides generated Python code for OpenTelemetry semantic conventions, enabling standardized attribute naming and constant definitions for instrumentation and telemetry collection.
Install it if you are using OpenTelemetry and want to follow semantic conventions correctly.
Provides the reference implementation of the OpenTelemetry API for collecting and exporting traces, metrics, and logs from Python applications.
Provides the abstract API and interfaces for OpenTelemetry instrumentation in Python, defining how to emit traces, metrics, and logs without tying code to a specific SDK implementation.
Exports OpenTelemetry observability data to an OpenTelemetry Collector using Protobuf-encoded messages over HTTP.
Install it if you are using OpenTelemetry in Python and need to send data to a Collector over HTTP.
Provides automatic instrumentation commands and programmatic APIs to inject distributed tracing into Python applications without code changes, detecting and instrumenting packages used by your program.
Install it if you need distributed tracing without code changes and have compatible instrumented packages in your environment.
See also libadvian · loguru · python-logging-loki · logger · python-json-logger · splunk-hec-handler · pygelf · cloudwatch · mcp-grafana · coralogix-logger