Skip to content

Instantly share code, notes, and snippets.

@kaihendry
Created September 21, 2024 19:14
Show Gist options
  • Save kaihendry/6ad32ed135e3d679e6dd896365b252cb to your computer and use it in GitHub Desktop.
Save kaihendry/6ad32ed135e3d679e6dd896365b252cb to your computer and use it in GitHub Desktop.
{"level":"info","ts":1726946030.4808884,"msg":"capture me monolog","syslog_level":"notice"}
<?php
require 'vendor/autoload.php';
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Formatter\JsonFormatter;
use Monolog\ErrorHandler;
$log = new Logger('name');
$stderrHandler = new StreamHandler('php://stderr', Logger::DEBUG);
$stderrHandler->setFormatter(new JsonFormatter());
$log->pushHandler($stderrHandler);
ErrorHandler::register($log);
$log->info('monolog test!');
error_log("capture me monolog");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment