PHP code example of logger / errorhandling

1. Go to this page and download the library: Download logger/errorhandling 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/ */

    

logger / errorhandling example snippets


use Logger\CoreErrorHandlers;
use Psr\Log\LogLevel;

// Turn PHP errors into exceptions (configurable mask, defaults to E_ALL)
CoreErrorHandlers::enableExceptionsForErrors();

// Log assertions through your PSR-3 logger at a chosen level
CoreErrorHandlers::registerAssertionHandler($logger, LogLevel::WARNING);

// Log uncaught exceptions (and print a compact stack trace to STDERR)
CoreErrorHandlers::registerExceptionHandler($logger);

// Log fatal errors such as E_ERROR/E_PARSE/E_CORE_ERROR/E_COMPILE_ERROR
CoreErrorHandlers::registerFatalErrorHandler($logger);