PHP code example of cmever / log

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

    

cmever / log example snippets


use cmever\Log\ESLog;
// 1. load autoload.php

// 2. init config
ESLog::setGlobalConfig([
    'log_url' => 'http://logserver',
    'server_name' => 'demo',
]);

// 3. use ESLog to log info
$logger = new ESLog();
$res = $logger->info('test.info', 'log info demo', [
    'key' => [
        'key1' => 'sec'
    ]
]);


use cmever\Log\ESLog;
// 1. load autoload.php
g_url' => 'http://logserver',
    'server_name' => 'demo',
]);

// 3. use ESLog to log info
$logger = new ESLog();
$res = $logger->info('test.info', 'log info demo', [
    'key' => [
        'key1' => 'sec'
    ]
]);

// 4. please to check es server logs
if ($res) {
    echo "Log successfully";
} else {
    echo "Log error!";
}

$logger = new ESLog();
$res = $logger->info('test.info', 'log info demo', [
    'key' => [
        'key1' => 'sec'
    ]
]);

ESLog::setGlobalConfig([
    'log_url' => 'http://logserver',
    'app_type' => 'demo',
]);

$logger = new ESLog();
$logger->setConfig([
    'log_url' => 'http://logserver',
    'server_name' => 'demo',
]);

$ php demos/simple_es_log.php
Log successfully