PHP code example of jmluang / logtailer-client-sdk
1. Go to this page and download the library: Download jmluang/logtailer-client-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Monolog\Logger;
use Monolog\Level;
use Jmluang\Logtailer\Monolog\LogtailHandler;
$logger = new Logger('my-app');
$handler = new LogtailHandler(
'your-source-token',
Level::Debug,
true,
'http://localhost:8080/logs'
);
$logger->pushHandler($handler);
// Use logger as normal
$logger->info('Application started');
$logger->error('An error occurred', ['error_code' => 500]);