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:
1
<?php
2
​
3
require "vendor/autoload.php";
4
​
5
use Monolog/Logger;
6
use Logtail/Monolog/LogtailHandler;
7
​
8
$logger = new Logger("example-app");
9
$logger->pushHandler(new LogtailHandler("<source-token>"));
10
​
11
$logger->info("logtail integration is ready");
12
$logger->warn("log structured data", [
13
"item" => [
14
"url" => "https://fictional-store.com/item-123",
15
"price" => 100
16
]
17
]);
Copied!
As a result, the following JSON rows will be ingested:
1
{
2
"dt": "2021-03-29T11:24:54.788Z",
3
"level": "info",
4
"message": "logtail integration is ready",
5
"monolog": {
6
"channel": "example-app"
7
}
8
}
9
​
10
{
11
"dt": "2021-03-29T11:24:54.788Z",
12
"level": "warn",
13
"message": "log structured data",
14
"monolog": {
15
"channel": "example-app",
16
"context": {
17
"item": {
18
"url": "https://fictional-store.com/item-123",
19
"price": 100
20
}
21
}
22
}
23
}
Copied!

Installation

Install the Logtail client library using Composer as you would with any other PHP package:
1
composer require logtail/monolog-logtail
Copied!
​
Last modified 2mo ago
Copy link