PHP code example of snakano / cakephp-monolog

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

    

snakano / cakephp-monolog example snippets



App::build([
	'Plugin' => [ROOT . DS . 'Plugin' . DS]
]);

CakePlugin::load('Monolog');

CakeLog::config('debug', array(
	'engine' => 'Monolog.Monolog',
	'channel' => 'app',
	'handlers' => array(
		'Stream' => array(
			LOGS . 'debug.log',
			'formatters' => array(
				'Line' => array("%datetime% %channel% %level_name%: %message%\n")
			)
		)
	)
));

CakeLog::config('logstash', array(
	'engine' => 'Monolog.Monolog',
	'channel' => 'app',
	'handlers' => array(
		'RotatingFile' => array(
			LOGS . 'application.log',
			30
		),
		'Stream' => array(
			LOGS . 'logstash.log',
			'formatters' => array(
				'Line' => array("%datetime% %channel% %level_name%: %message%\n")
			),
			'processors' => array(
				'DatadogProcessor' => array(
					'search' => CakePlugin::path('Monolog') . 'Lib' . DS . 'Log' . DS . 'Processor'
				),
				'MemoryUsage' => array(),
				'Web' => array()
			)
		),
		'CakeEmail' => array(
			'[email protected]',
			'ALERT: APPLICATION REQUIRES IMMEDIATE ATTENTION.',
			'default'
		)
	)
));