PHP code example of contenir / contenir-log

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

    

contenir / contenir-log example snippets


return [
    'log' => [
        'storage' => [
            // 'filesystem' (default) or 'db' — both are registered aliases.
            // You can also name any service id implementing StorageInterface.
            'adapter' => 'db',

            // Options for the chosen adapter:
            'options' => [
                // db:
                'adapter' => Laminas\Db\Adapter\Adapter::class, // db adapter service id
                'table'   => 'log',
                // LogRecord field => table column (only mapped fields are written;
                // a createdAt column with a DB default can be left out).
                'columns' => [
                    'message'      => 'message',
                    'error'        => 'error',
                    'priority'     => 'priority',
                    'priorityName' => 'priorityName',
                ],
                // Optional: route individual PSR-3 context entries to their own
                // columns. Only keys present on a given record are written, so a
                // domain id like student maps straight to an indexable column.
                'context' => [
                    'student' => 'student_id',
                ],

                // filesystem:
                // 'path' => 'data/log/app.log',
            ],
        ],
    ],
];

$logger->error('HTTP 500 at {uri}', ['uri' => $uri, 'exception' => $e]);