Links

PHP

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

Example

It's very easy to start sending logs to Logtail:
<?php
require "vendor/autoload.php";
use Monolog/Logger;
use Logtail/Monolog/LogtailHandler;
$logger = new Logger("example-app");
$logger->pushHandler(new LogtailHandler("<source-token>"));
$logger->info("logtail integration is ready");
$logger->warn("log structured data", [
"item" => [
"url" => "https://fictional-store.com/item-123",
"price" => 100
]
]);
As a result, the following JSON rows will be ingested:
{
"dt": "2021-03-29T11:24:54.788Z",
"level": "info",
"message": "logtail integration is ready",
"monolog": {
"channel": "example-app"
}
}
{
"dt": "2021-03-29T11:24:54.788Z",
"level": "warn",
"message": "log structured data",
"monolog": {
"channel": "example-app",
"context": {
"item": {
"url": "https://fictional-store.com/item-123",
"price": 100
}
}
}
}

Installation

Install the Logtail client library using Composer as you would with any other PHP package:
composer require logtail/monolog-logtail