PHP code example of roma-glushko / monolog-parser

1. Go to this page and download the library: Download roma-glushko/monolog-parser 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/ */

    

roma-glushko / monolog-parser example snippets



  
use MonologParser\Reader\LogReader;
    
$logFile = '/path/to/some/monolog.log';
$reader = new LogReader($logFile);
   
foreach ($reader as $i => $log) {
    echo sprintf(
      "The #%s log entry was written at %s. \n", 
      $i, 
      $log['date']->format('Y-m-d h:i:s')
    );
}
    
$lastLine = $reader[count($reader)-1];
echo sprintf(
  "The last log entry was written at %s. \n", 
  $lastLine['date']->format('Y-m-d h:i:s')
);