1. Go to this page and download the library: Download sesser/slogger 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/ */
$serializer = function($obj) {
if (is_string($obj))
return $obj;
return json_encode($obj, true);
};
//-- Somewhere in your application...
Slogger::Configure('MyLogger', array(
'provider' => 'File',
'settings' => array(
'enabled' => true,
'level' => \Sesser\Slogger\Slogger::LOG_LEVEL_DEBUG,
'logfile' => '/tmp/myapp.log',
'serializer'=> $serializer
)));
//-- When you need your logger... get it
$log = Logger::Get('MyLogger');
$log->Debug("This is a debug message");
$log->Error("Exception caught! See below");
$log->Error($ex);