1. Go to this page and download the library: Download cndrsdrmn/http-logger 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/ */
cndrsdrmn / http-logger example snippets
return [
/*
|-----------------------------------------------------------
| HTTP Logger Channel
|-----------------------------------------------------------
*/
'channel' => env('HTTP_LOGGER_CHANNEL', env('LOG_CHANNEL', 'stack')),
/*
|-----------------------------------------------------------
| Masking Fields
|-----------------------------------------------------------
|
| Sometimes you need to keep field values secretly.
| You can register a field on this "masking" key to keep its value secret.
| Masked a request "body", "query" and "headers".
*/
'masking' => [
'password',
'password_confirmation',
],
/*
|-----------------------------------------------------------
| Skip Endpoints
|-----------------------------------------------------------
|
| Sometimes, you need to skip recording a log for whitelist endpoints.
| Example: '/foo/bar', '/foo/*'
*/
'skip_endpoints' => [],
/*
|-----------------------------------------------------------
| Skip IPs Address
|-----------------------------------------------------------
|
| Sometimes, you need to skip recording a log for whitelist IPs address.
| Example: '192.168.0.10', '172.10.0.*', '172.9.*',
*/
'skip_ips' => [],
];
// in app/Http/Kernel.php
protected $middleware = [
// ...
\Cndrsdrmn\HttpLogger\Middleware\HttpLogger::class,
];
// in a routes file
Route::post('foo', function () {
// action here
})->middleware(\Cndrsdrmn\HttpLogger\Middleware\HttpLogger::class);
// in bootstrap/app.php
// Global Middleware
$app->middleware([
\Cndrsdrmn\HttpLogger\Middleware\HttpLogger::class,
]);
// OR Assigning Middleware To Routes
$app->routeMiddleware([
'http-logger' => \Cndrsdrmn\HttpLogger\Middleware\HttpLogger::class,
]);
// in routes file
$router->get('/', ['middleware' => ['http-logger'], function () {
//
}]);