PHP code example of sesser / slogger

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/ */

    

sesser / slogger example snippets



$config = array(
	'enabled'	 => false,
	'logfile'	 => dirname(dirname(__FILE__)) . 'tmp/logs/application.log',
	'level'		 => \Sesser\Slogger\Slogger::LOG_LEVEL_ERROR,
	'serializer' => NULL,
	'dateFormat' => 'Y-m-d H:i:s'
);



$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);


$log = Slogger::Get('MyLogger');


	$config = array(
		'enabled'	=> false,
		'level'		=> \Sesser\Slogger\Slogger::LOG_LEVEL_ERROR,
		'server'	=> array(
			'dsn'		=> 'mongodb://127.0.0.1:27017',
			'db'		=> 'applog',
			'options'	=> array(
				'timeout' => 1000
			)
		),
		'serializer' => NULL
	);