explaingit

seldaek/monolog

21,390PHPAudience · developerComplexity · 2/5MaintainedLicenseSetup · easy

TLDR

PHP logging library that sends application messages to multiple destinations (files, email, databases, monitoring services) with customizable formatting and filtering.

Mindmap

mindmap
  root((Monolog))
    What it does
      Records app events
      Routes to destinations
      Formats output
    Key concepts
      Handlers route logs
      Processors add context
      Formatters style output
    Destinations
      Files and sockets
      Email and databases
      External services
    Use cases
      Error tracking
      Audit logging
      Performance monitoring
    Tech stack
      PHP 8.1+
      Composer
      PSR-3 standard

Things people build with this

USE CASE 1

Send application errors to email and a monitoring service simultaneously while keeping a local backup log file.

USE CASE 2

Add request IDs and user information to every log entry automatically using processors.

USE CASE 3

Filter debug messages to a development log file while sending only errors and warnings to production monitoring.

USE CASE 4

Integrate logging into a Laravel or Symfony app without writing custom code, since those frameworks use Monolog by default.

Tech stack

PHPComposer

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

Monolog is a PHP logging library, a tool for recording events, errors, and diagnostic messages from your application to a variety of destinations. Rather than using PHP's built-in error logging (which only writes to a single file), Monolog lets you send log messages to multiple places simultaneously and in different formats. The library uses a concept called "handlers", pluggable components that each know how to send a log message somewhere. You stack multiple handlers on a logger, and each message flows through them. Destinations include local files, system log sockets, email inboxes, databases, and many external web services and monitoring platforms. You can also attach "processors" that add extra information to log records (like the current user, request ID, or memory usage) and "formatters" that control how the output looks. Monolog implements PSR-3, which is a community standard interface for PHP loggers. Because it follows this standard, it integrates out of the box with many popular PHP frameworks, including Symfony, Laravel, and others, those frameworks use Monolog as their built-in logger. The library handles standard log severity levels (debug, info, warning, error, critical, etc.), and you can configure each handler to only process messages above a certain severity. Monolog version 3 requires PHP 8.1 or later. You install it using Composer, the standard PHP package manager. It is open source under the MIT license.

Copy-paste prompts

Prompt 1
Show me how to set up Monolog to log errors to both a file and email using handlers and processors.
Prompt 2
How do I configure Monolog to send critical errors to a Slack channel while keeping debug logs local?
Prompt 3
Write a Monolog setup that adds the current user ID and request ID to every log entry automatically.
Prompt 4
How do I use Monolog's severity levels to send only warnings and errors to an external monitoring service?
Prompt 5
Show me how to integrate Monolog into a Laravel app and customize the log format.
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.