mondospedizioni/monolog-logtail

Logtail handler for Monolog 3

dev-master 2023-01-18 11:56 UTC

This package is auto-updated.

Last update: 2024-05-18 16:31:16 UTC


README

Logtail dashboard

License: ISC Unit tests PHP version

Collect logs from your PHP projects, including Laravel, Symfony, CodeIgniter, CakePHP, Zend, and more.

Logtail is a hosted service that centralizes all of your logs into one place. Allowing for analysis, correlation and filtering with SQL. Actionable Grafana dashboards and collaboration come built-in. Logtail works with any language or platform and any data source.

Features

  • Simple integration. Built on well-known Monolog logging library.
  • Support for structured logging and events.
  • Automatically captures useful context.
  • Performant, light weight, with a thoughtful design.

Supported language versions

  • PHP 8 or newer
  • Composer 1.10.1 or newer

Installation

Install the Logtail Monolog library using composer:

composer require logtail/monolog-logtail

Example project

To help you get started with using Logtail in your PHP projects, we have prepared a simple program that showcases the usage of Logtail logger.

Download and install the example project

You can download the example project from GitHub directly or you can clone it to a select directory. In that directory, run the following command:

composer update

This command will install all dependencies from composer.json file and lock them in composer.lock file.

Run the example project

To run the example application, simply run the following command:

php index.php <source-token>

Don't forget to replace <source-token> with your actual source token which you can find by going to logtail.com -> sources -> edit.

You should see the following output:

All done, you can check your logs in the control panel.

This will create and send a total of 8 log messages to the Logtail. Each message corresponds to a specific log level. Detail explanation follows below.

Explore how example project works

Learn how to setup PHP logging by exploring the workings of the example project in detail.

Improved performance with batches

We extend Monolog\Handler\BufferHandler to send your logs periodically in batches for optimized network traffic by default. If you don't want to use batches or you want to use your own buffer handler, use SynchronousLogtailHandler instead.

Get in touch

Have any questions? Please explore the Logtail documentation or contact our support.