tamert / monolog-loki
Monolog handler for Grafana Loki (PHP 7.2 compatible)
Installs: 53
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/tamert/monolog-loki
Requires
- php: >=7.2
- monolog/monolog: ^2.0
This package is auto-updated.
Last update: 2025-12-17 13:16:59 UTC
README
Loki handler for Monolog, providing a formatter that serializes records into the JSON format expected by Grafana Loki.
Table of Contents
Installation
Require the package via Composer:
composer require tamert/monolog-loki
Usage
Below is a minimal example showing how to send logs to a Loki server:
use Monolog\Level; use Monolog\Logger; use Tamert\Monolog\Loki\LokiHandler; $handler = new LokiHandler( 'http://your-loki-host:3100', ['app'=>'My application', 'env'=>'production'], 'debug' ); $logger = new Logger('loki'); $logger->pushHandler($handler); $logger->info('User signed in', ['user_id' => 123]);
Contributing
Contributions are very welcome! Please:
- Fork the repository.
- Create a feature branch (
git checkout -b feature/YourFeature). - Make your changes, ensuring all tests pass and coding standards are met.
- Submit a pull request.
