PHP code example of senzidee / monolog-parseable-handler

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

    

senzidee / monolog-parseable-handler example snippets




use Monolog\Logger;
use SenzaIdee\Handler\ParseableHandler;

// Create the handler
$handler = new ParseableHandler(
    host: 'https://your-parseable-instance.com',
    stream: 'application-logs',
    username: 'your-username',
    password: 'your-password',
    port: 8000
);

// Create logger and add handler
$logger = new Logger('app');
$logger->pushHandler($handler);

// Start logging
$logger->info('Application started');
$logger->error('Something went wrong', ['error_code' => 500]);

$handler = new ParseableHandler(
    host: 'https://logs.company.com',
    stream: 'api-logs',
    username: 'api-user',
    password: 'secure-password'
);

$handler = new ParseableHandler(
    host: 'https://prod-logs.company.com',
    stream: 'production-app',
    username: $_ENV['PARSEABLE_USERNAME'],
    password: $_ENV['PARSEABLE_PASSWORD'],
    port: 443,
    level: Level::Warning, // Only log warnings and above
    bubble: false
);