1. Go to this page and download the library: Download robmellett/http-logging 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/ */
robmellett / http-logging example snippets
// config for RobMellett/HttpLogging
return [
/*
* The Laravel Log Channel to send logs to.
*/
'channel' => 'http_logs',
/*
* Customize how the Secure Json Formatter redacts secrets.
*/
'secure_json_formatter' => [
/*
* Secret Values will be replaced with this value.
*/
'redacted_value' => '[--REDACTED--]',
/*
* By default, we will attempt to look for secrets in the Laravel 'config/services.php'.
*
* Any values that contain the following words will be redacted:
* "key", "secret", "password", "hash", "token"
*/
'extract_service_secrets' => true,
/*
* Specific values to redact from the logs.
*/
'secrets' => [
// e.g
// env('API_SECRET'),
],
/*
* Regular expressions to redact from the logs.
*/
'regexes' => [
// e.g
// '/Bearer\s\w+/',
],
],
];
use RobMellett\HttpLogging\HttpLogging;
Http::withMiddleware(new HttpLogging())
->asJson()
->get('https://jsonplaceholder.typicode.com/posts');
// config/logging.php
'channels' => [
// ...Previous config
'http_logs' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
// This will remove sensitive values such as "key", "secret", "hash", "token" from the logs
'formatter' => RobMellett\HttpLogging\Support\SecureJsonFormatter::class
// Or if you would prefer to send sensitive data to the logs
//'formatter' => Monolog\Formatter\JsonFormatter::class,
],
]