PHP code example of sitecrafting / monolog-masking-formatter

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

    

sitecrafting / monolog-masking-formatter example snippets




use Monolog\Handler\RotatingFileHandler;
use MaskingFormatter\LogstashFormatter as MaskingLogstashFormatter;

// configure a formatter
$formatter = new MaskingLogstashFormatter('my-app');
$formatter->maskFields(['sensitive', 'context', 'keys']);
$formatter->setMask('********');

// instantiate a handler and add our formatter
$handler = new RotatingFileHandler('./log/app.log', 7, Logger::DEBUG);
$handler->setFormatter($formatter);

// create a logger and push the handler per usual...