PHP code example of repejota / monolog-nats

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

    

repejota / monolog-nats example snippets



Nats\Connection;

use Monolog\Logger;
use Monolog\Handler\NatsHandler;

$nats = new Connection();
$nats->connect();

$logger = new Logger("monolog-nats-logger");
$natsHandler = new NatsHandler($nats);
$logger->pushHandler($natsHandler);

$logger->info("Info log");