PHP code example of elavora / api-log-file

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

    

elavora / api-log-file example snippets


use Elavora\Api\Extension\LogFile\FileLogExtension;
use Elavora\Api\Framework\Logging\Logger;

$application->extend(new FileLogExtension([
    'path' => __DIR__ . '/../storage/logs/app.log',
]));

$application->container()
    ->get(Logger::class)
    ->info('Requisicao recebida', ['route' => '/health']);

[
    'timestamp' => gmdate('c'),
    'level' => 'info',
    'message' => 'Requisicao recebida',
    'request_id' => '...',
    'context' => [],
]