
Monolog
A PHP logging library that writes logs to files, sockets, email, databases and web services.
- Stars
- 21.4k
- Forks
- 1.9k
- Licence
- MIT
- Language
- PHP
- Last update
- 5 days ago
- Type
- Library
What it is
Monolog is a logging library for PHP applications. It records messages and sends them to destinations such as files, network sockets, email inboxes, databases and various web services. It implements the PSR-3 logger interface, so other PHP libraries can write logs through a common API.
- Write warnings and errors from a PHP app to a log file with StreamHandler
- Send high-severity log records to an email inbox or external service via built-in handlers
- Use PSR-3 log levels in a library so it works with any compatible logger
- Combine several handlers and processors to build a custom logging strategy
Great for
- PHP developers who need structured logs from an application
- Teams using frameworks such as Symfony or Laravel, which the README says ship with Monolog
- Library authors who want to type-hint against the PSR-3 logger interface
- Projects that need to send the same logs to several destinations
Not ideal for
- Non-PHP projects, since the library is written for PHP (requires PHP 8.1+ for version 3.x)
- People on very old PHP versions, since version 1.x is described as not very maintained
- Non-developers looking for a finished log viewer; the README covers the library, not a dashboard
How to get it
- 1
Install with a package manager
You'll need: PHP 8.1 or above (for Monolog 3.x) · Composer
Install with Composer
composer require monolog/monolog - 2
Run it
- Install the package with Composer using the command above.
- Create a logger with new Logger('name').
- Attach a handler such as StreamHandler with a file path and minimum level.
- Call methods like warning() or error() to write records.
- 3
Get the most out of it
- Use the handlers, formatters and processors documentation to choose the right output format and destination.
- Use PSR-3 log levels in shared libraries so they stay compatible with other loggers.
- Check the third-party packages list in the project wiki for extra handlers and formatters.
- Read the log record structure documentation to understand what each record contains.
Downloads
Strengths
- Widely used, with a large star count and active recent pushes
- Implements the PSR-3 standard, improving interoperability with other libraries
- Offers many handlers and a documented extension model
Trade-offs
- Requires understanding of handlers, levels and channels before setup is straightforward
- Version 1.x support is limited and version 2.x and 3.x require different PHP versions
- The README is truncated here, so detailed handler configuration is in separate docs
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| monolog (this) | 21.4k | Library | intermediate | 5 days ago | PHP developers who need structured logs from an application |
| loguru | 24.2k | Library | beginner | 11 days ago | Python developers who want logging without much setup |
| Slim | 12.3k | Framework | intermediate | 5 days ago | PHP developers who want a lightweight alternative to a full-stack framework |
| logrus | 25.8k | Library | beginner | 1 months ago | Go developers with existing code that already uses Logrus |
| zap | 24.7k | Library | beginner | 2 months ago | Go developers building services that log heavily |
| guzzle | 23.4k | Library | intermediate | 11 days ago | PHP developers who need to call external REST or web service APIs |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.