PHP code example of munir131 / monolog-google-cloud-json-formatter

1. Go to this page and download the library: Download munir131/monolog-google-cloud-json-formatter 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/ */

    

munir131 / monolog-google-cloud-json-formatter example snippets


use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Superbalist\Monolog\Formatter;

// create a handler
$handler = new StreamHandler('path/to/your.log', Logger::WARNING);

// use custom formatter in handler
$handler->setFormatter(new GoogleCloudJsonFormatter());

// create a log channel
$log = new Logger('name');
$log->pushHandler($handler);

// add records to the log
$log->addWarning('Foo');
$log->addError('Bar');