1. Go to this page and download the library: Download reactphp-x/log 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/ */
reactphp-x / log example snippets
use React\Stream;
use ReactphpX\Log\ConsoleFormatter;
use ReactphpX\Log\StreamHandler;
use ReactphpX\Log\FileWriteStream;
use Monolog\Logger;
ess:
$handler = new StreamHandler(new Stream\WritableResourceStream(STDOUT));
$handler->setFormatter(new ConsoleFormatter);
$logger = new Logger('main');
$logger->pushHandler($handler);
$logger->debug("Hello, world!");
$logger->info("Hello, world!");
$logger->notice("Hello, world!");
$logger->error("Hello, world!");
$logger->alert("Hello, world!");
use ReactphpX\Log\Log;
stdout)
Log::info('Hello from Log facade');
Log::error('Something went wrong', ['code' => 123]);
// Optional: configure channels
Log::configure([
'default' => 'stdout',
'channels' => [
'single' => ['driver' => 'single', 'path' => __DIR__ . '/example.log', 'formatter' => 'line'],
'stdout' => ['driver' => 'stdout', 'formatter' => 'console'],
'stderr' => ['driver' => 'stderr', 'formatter' => 'console'],
'stacked' => ['driver' => 'stack', 'channels' => ['stdout', 'single']],
],
]);
Log::channel('single')->warning('This goes to a file');
Log::stack(['stdout', 'single'])->notice('This appears in both stdout and file');
bash
php examples/log-facade.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.