Logtail
What is Logtail?
Get help
Book a demo
System Status
Searchβ¦
Getting started
βοΈ Sources
JavaScript
Python
Ruby
PHP
.NET
Java
Heroku
Render
Kubernetes
Docker
Dokku
Cloudflare
HTTP REST API
Nginx
Apache2
Redis
MongoDB
PostgreSQL
MySQL
Ubuntu
π
Integrations
Slack
ποΈ Log forwarding
Vector (recommended)
Fluent Bit
Logstash
Fluentd
Syslog
π§
API
Getting Started
Sources API
π
How-to Guides
GeoIP map visualization
AWS S3-compatible archive
String + JSON format
Live Tail Query Language
Tutorials
Powered By
GitBook
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!
β
βοΈ Sources - Previous
Ruby
Next - βοΈ Sources
.NET
Last modified
9mo ago
Copy link
Contents
Example
Installation