explaingit

seldaek/monolog

21,396PHPAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

Monolog is a PHP library for recording logs from your application to multiple destinations at once, files, email, databases, or monitoring services, through a pluggable handler system.

Mindmap

mindmap
  root((repo))
    What it does
      Record app events
      Multiple destinations
      Severity filtering
    Key concepts
      Handlers
      Processors
      Formatters
    Tech Stack
      PHP 8.1+
      Composer
      PSR-3 standard
    Use cases
      Error alerting
      Debug logging
      Framework integration
    Audience
      PHP developers
      Framework users
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Send application errors to a log file and an email inbox at the same time using stacked handlers.

USE CASE 2

Automatically attach contextual data like request IDs or memory usage to every log entry via processors.

USE CASE 3

Integrate structured logging into a Symfony or Laravel application using Monolog as the built-in logger.

USE CASE 4

Route only critical-severity messages to an external monitoring service while keeping debug logs local.

Tech stack

PHPComposer

Getting it running

Difficulty · easy Time to first run · 5min

Install via Composer in one command, requires PHP 8.1 or later.

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
How do I set up Monolog in a PHP project to write errors to a rotating file and also send critical alerts to Slack?
Prompt 2
Show me how to add a Monolog processor that automatically attaches the current user ID to every log message.
Prompt 3
How do I configure a Monolog handler to only process messages above the WARNING severity level?
Prompt 4
Write a PHP snippet using Monolog to log to both a local file and a remote syslog server simultaneously.
Prompt 5
How does Monolog's PSR-3 compatibility let me swap out the logger in a Symfony app without changing my code?
Open on GitHub → Explain another repo

← seldaek on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.