Generated by GPT-5-mini| monolog/monolog | |
|---|---|
| Name | monolog/monolog |
| Developer | Seldaek (Jordi Boggiano) and contributors |
| Released | 2010 |
| Programming language | PHP |
| Platform | Cross-platform |
| Repository | GitHub |
| License | MIT License |
monolog/monolog
Monolog is a widely used PHP logging library designed to send log messages to multiple destinations. It originated as an open-source project and has been adopted in frameworks and applications across the PHP ecosystem. Monolog is integrated with popular projects and influenced logging practices in web applications, microservices, and command-line tools.
Monolog provides a PSR-compliant logging API and a set of handlers to route messages to services and stores. Implementations of Monolog are used in conjunction with frameworks, libraries, and infrastructure components such as Symfony, Laravel, Zend Framework, Slim (framework), CakePHP, Drupal, WordPress, Composer (software), Packagist, GitHub, GitLab, and Bitbucket. Its design addresses requirements faced in deployments with Amazon Web Services, Microsoft Azure, Google Cloud Platform, Heroku, Docker, Kubernetes, NGINX, and Apache HTTP Server. Because Monolog interoperates with PSR standards, it is often mentioned alongside PHP-FIG, PSR-3, PSR-7, PSR-4, and PSR-11.
Monolog implements severity levels compatible with logging standards and provides formatters and processors for message enrichment. Handlers include adapters for services like Syslog, Logstash, Graylog, Papertrail, Sentry (software), New Relic, Datadog, Elasticsearch, MySQL, PostgreSQL, SQLite, MongoDB, Redis, Amazon S3, and Sendmail. Features include channel-based logging, stream rotation, buffer handlers, and processors for adding context such as stack traces and HTTP request metadata. The project’s extensibility allows integration with event systems used by Symfony EventDispatcher, Zend EventManager, Laravel Events, and job queues like RabbitMQ, Apache Kafka, Beanstalkd, and Amazon SQS.
Monolog is installed via Composer (software), the dependency manager for PHP, and is configured in application bootstrap code or framework configuration files. Typical usage shows how to instantiate a logger, push handlers, and call methods corresponding to levels defined by PSR-3 such as emergency, alert, critical, error, warning, notice, info, and debug. In frameworks, Monolog setup is often automated by integrations in Symfony Bundle, Laravel Service Container, Slim middleware, or Drupal module scaffolding. Deployment to platforms like Heroku, AWS Elastic Beanstalk, Azure App Service, Google App Engine or container orchestrators such as Kubernetes follows standard environment variable and secrets management practices.
Monolog’s architecture centers on Logger, Handler, Formatter, and Processor abstractions. The Logger receives messages and dispatches them to one or more Handlers which decide whether to handle a record and in which format. Formatters transform records into serializations suitable for targets such as JSON for Logstash or GELF for Graylog. Processors augment records with contextual information (e.g., request IDs) and integrate with tracing and observability tools like OpenTracing, OpenTelemetry, Jaeger, and Zipkin. The repository and its contributors adhere to coding standards used by PHP Standards Recommendation, test suites often use PHPUnit, continuous integration pipelines run on Travis CI, GitHub Actions, or CircleCI, and package distribution leverages Packagist and Composer.
Monolog ships with numerous built-in handlers and community-contributed adapters. Built-in handlers target local files, system logs, remote syslog servers, sockets, email transports, and databases such as MySQL and PostgreSQL. Community handlers enable delivery to SaaS and observability platforms like Sentry (software), New Relic, Datadog, Papertrail, Loggly, Sumo Logic, Rollbar, and Raygun. Integrations with frameworks, deployment platforms, and infrastructure tools ensure logs flow to central services used in observability stacks alongside Elasticsearch, Kibana, Grafana, and Prometheus.
Monolog’s development is hosted on GitHub where contributors collaborate through issues, pull requests, and releases. The project has attracted contributions from many PHP community members and is referenced in community resources such as tutorials, books, and conference talks at events like SymfonyCon, Laracon, PHP UK Conference, php[tek], and regional meetups. Governance follows open-source practices with maintainers reviewing changes; CI/CD workflows, code review, and automated test suites enforce quality. Monolog’s interoperability with ecosystem projects like Composer (software), Packagist, Symfony, Laravel, and Drupal helps maintain its relevance.
Monolog is distributed under the MIT License, a permissive open-source license that allows use in commercial and proprietary applications. Security considerations include safe handling of sensitive data such as credentials, Personally Identifiable Information, and tokens when logging; recommended practices align with guidance from platforms like OWASP and standards organizations including ISO and NIST. Vulnerability disclosures and patches are managed via issue tracking on GitHub and coordinated advisories through the broader PHP community and package repositories.
Category:PHP libraries