psr/log

The PSR-3 common logger interface that lets PHP libraries accept any logger without depending on a specific implementation.

Library
Composer
v3.0.2
10,419 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
45 /100 Fair
Development Activity 4
Maintenance 20
Community 56
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
71 /100 Good
Architecture 65
Code Quality 75
Innovation 55
Learning Curve 90

psr/log is the reference implementation of PSR-3, the PHP-FIG standard that defines a common LoggerInterface for logging libraries. It ships no logging backend of its own — no file writers, no formatters — only the interface, a LogLevel constants class, an AbstractLogger/LoggerTrait base implementation, a NullLogger no-op, and a LoggerAwareInterface/LoggerAwareTrait pair for injecting a logger into consumer classes. Because nearly every major PHP framework and logging library (Monolog, Symfony, Laravel’s underlying stack, Guzzle) type-hints against Psr\Log\LoggerInterface rather than a concrete class, packages that accept a PSR-3 logger can be wired up to whichever logging implementation the application already uses, with zero coupling to that implementation’s internals.

What You Get

  • Psr\Log\LoggerInterface with the eight RFC 5424 severity levels (emergency, alert, critical, error, warning, notice, info, debug) plus a generic log($level, $message, $context) method
  • Psr\Log\LogLevel — a constants class enumerating the eight level strings for type-safe comparisons
  • Psr\Log\AbstractLogger and Psr\Log\LoggerTrait — base implementations that let you implement only log() and get the eight level-specific methods for free
  • Psr\Log\NullLogger — a no-op implementation for disabling logging or satisfying a required constructor argument in tests
  • Psr\Log\LoggerAwareInterface and Psr\Log\LoggerAwareTrait — a standard setLogger() contract for injecting a logger into any class after construction

Common Use Cases

  • Accepting an optional logger constructor argument in a library so consumers can plug in Monolog, Symfony’s logger, or any PSR-3-compatible implementation
  • Writing framework-agnostic packages that need to emit log messages without pulling in a concrete logging dependency
  • Using NullLogger as a safe default when no logger is configured, avoiding null checks scattered through the codebase
  • Implementing LoggerAwareInterface so a DI container can inject a logger into any service that declares the trait

Under The Hood

Architecture - The package is purely a set of interfaces, a small enum-like constants class (LogLevel), and thin trait/abstract-class helpers; there is no runtime logic beyond LoggerTrait::log() delegating to the appropriate level method and NullLogger swallowing all calls. Consumers depend on LoggerInterface and receive whatever concrete logger implementation (e.g. Monolog) the application wires in, so the actual log-writing behavior lives entirely outside this repository. Tech Stack - Plain PHP 8+ with PSR-4 autoloading (Psr\Log\ mapped to src/) and no runtime dependencies at all; the package only declares a php: >=8.0.0 platform requirement in composer.json. Code Quality - The codebase is deliberately minimal — eight small files, each under 100 lines, with typed method signatures and PHPDoc blocks on every interface method describing expected $level, $message, and $context semantics; there is no test suite in the repository since there is no executable behavior to test beyond NullLogger and LoggerTrait, which are exercised indirectly by every downstream implementation’s own test suite. API Design - The interface mirrors the RFC 5424 syslog severity levels exactly, which any PHP developer already familiar with logging conventions will recognize instantly; the eight level methods plus one generic log() method give implementers freedom in how messages are formatted while giving consumers a single, ubiquitous type to depend on.

Used by 6 apps in this directory

PHP
66%
AGPL 3.0

EspoCRM

CRM · Ecommerce · Marketing

3,354

Open-source CRM platform with metadata-driven customization, field-level permissions, and a full REST API — deploy on your own infrastructure.

View details
97
Repo Health
72
Technical
63
Dependency
Built with
PHP 66%
JavaScript 23%
Updated 1 weeks ago
PHP
91%
AGPL 3.0

FreeScout

Customer Support

4,534

Run your own help desk and shared inbox — a fully self-hosted, open-source alternative to Zendesk and Help Scout with no per-agent fees.

View details
93
Repo Health
55
Technical
63
Dependency
Built with
PHP 91%
Updated 1 weeks ago
PHP
86%
AGPL 3.0

Kimai

Invoicing Finance · Project Management

4,996

Professional open-source time tracking with invoicing, multi-user support, SAML/LDAP auth, and a full REST API—self-host it or use the cloud.

View details
94
Repo Health
78
Technical
64
Dependency
Built with
PHP 86%
Updated 1 weeks ago
Other

Magic

AI Agents · Automation · Low Code Platforms

5,032

Magic is an enterprise-grade open-source AI agent platform combining a generalist AI agent, workflow engine, IM, and collaborative office system for running an AI-powered digital workforce.

View details
71
Repo Health
79
Technical
0
Dependency
PHP
78%
GPL 3.0

matomo

Analytics

21,866

Open-source, privacy-first web and app analytics that puts you in complete control of your data.

View details
95
Repo Health
82
Technical
62
Dependency
Built with
PHP 78%
Updated 1 weeks ago
PHP
84%
MIT

wallabag

Bookmarks Archiving

12,965

Self-hosted read-it-later app that saves clean, ad-free articles from any webpage for distraction-free reading across all your devices.

View details
93
Repo Health
81
Technical
60
Dependency
Built with
PHP 84%
Twig 13%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers