Universal TypeScript and JavaScript logger with pretty terminal output, structured fields-first JSON, secret masking and zero runtime dependencies.
Seldaek/monolog
A PHP logging library that sends logs to files, sockets, email, databases and various web services, implementing PSR-3.
- Stars
- 21,403
- Forks
- 1,919
- Open issues
- 12
- Last commit
- 18 days ago
What is it?
Monolog is a logging library for PHP. It routes log records to a wide range of destinations through handlers, including files, sockets, inboxes, databases and various web services. Special handlers let you combine destinations into more advanced logging strategies.
The library implements the PSR-3 logger interface, so libraries can type-hint against it and applications can swap in another PSR-3 compatible logger later. Log levels follow Monolog's own scheme, and public APIs also accept PSR-3 levels.
Monolog 3.x requires PHP 8.1 or above, and 2.x and 1.x branches are available for older PHP versions. Symfony, Laravel and Lumen ship with it, and it can be used with several other PHP frameworks through plugins.
Key features
- 01Handlers send logs to files, sockets, email, databases and web services.
- 02Handlers, formatters and processors can be combined into custom logging pipelines.
- 03Implements the PSR-3 logger interface for interoperability.
- 04Accepts both Monolog log levels and PSR-3 log levels.
Use cases
- Writing application logs to files in a PHP web application.
- Sending error logs to an external service or inbox for alerting.
- Building a logging setup that writes to several destinations at once.
- Writing a PHP library that logs through the standard PSR-3 interface.
Quick start
- 1
Install Monolog with Composer
composer require monolog/monolog - 2
Create a logger and add a file handler
- 3
Write log records with the logger
Things to know
- Requires PHP 8.1 or above for Monolog 3.x; older PHP versions need Monolog 2.x or 1.x.
In collections
Topics
FAQ
- What is monolog?
- A PHP logging library that sends logs to files, sockets, email, databases and various web services, implementing PSR-3. Monolog is a logging library for PHP. It routes log records to a wide range of destinations through handlers, including files, sockets, inboxes, databases and various web services. Special handlers let you combine destinations into more advanced logging strategies.
- Is monolog free to use? What license does it have?
- monolog is open source under the MIT license. Check the license terms before using it in commercial products.
- Is monolog still maintained?
- Actively maintained. The last commit to monolog was on Oct 5, 2026.
- What can I use monolog for?
- Writing application logs to files in a PHP web application. Sending error logs to an external service or inbox for alerting. Building a logging setup that writes to several destinations at once. Writing a PHP library that logs through the standard PSR-3 interface.
- How do I install monolog?
- Install Monolog with Composer: composer require monolog/monolog Create a logger and add a file handler Write log records with the logger
- Where can I get monolog?
- The source code and installation instructions are on GitHub: https://github.com/Seldaek/monolog
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Horizontally scalable, multi-tenant log aggregation system that indexes only labels, not log contents, from Grafana Labs.
Graylog is a free, open log management platform for collecting, searching and analyzing log data.
Python logging library that replaces the standard logging setup with a single logger, file rotation, colored output and structured logs.
Open-source, OpenTelemetry-native observability platform that brings logs, metrics, traces, alerts and dashboards into one self-hostable tool.
Structured, API-compatible logger for Go with pluggable formatters and hooks, now in maintenance mode.