A Laravel 5 package to log HTTP requests
bwt-team/laravel-request-logger is a Laravel package for a laravel 5 package to log http requests.
It currently has 2 GitHub stars and 5.817 downloads on Packagist (latest version v1.0.5).
Install it with composer require bwt-team/laravel-request-logger.
Discover more Laravel packages by bwt-team
or browse all Laravel packages to compare alternatives.
Last updated
English description | Russian description
This package provides quick and easy setup for the requests logging.
This package can be installed via composer with this command:
composer require bwt-team/laravel-request-logger
Laravel 5.6+ uses package auto-discovery, so there's no need to register the service provider manually.
If auto-discovery is disabled the service provider can be registered by adding these records into providers array in config/app.php file:
BwtTeam\LaravelRequestLogger\Providers\RequestLoggerServiceProvider::class
This service provider will register the middleware that calls the logging itself and will allow configuring all the settings required for the package installation.
To use a facade add this record to the aliases array:
'RequestLogger' => \BwtTeam\LaravelRequestLogger\Facades\RequestLogger::class,
Here's an example of the function that describes the logging conditions:
'enabled' => function(\Illuminate\Http\Request $request) {
return $request->isMethod('GET');
},
In order to publish the config file execute next command:
php artisan vendor:publish --provider="BwtTeam\LaravelRequestLogger\Providers\RequestLoggerServiceProvider" --tag=config
Next options are available in the settings:
The default log storage is "database". For this storage to work correctly it is necessary to execute a migration to create a table for logs. In order to publish this migration execute this command:
php artisan request-logger:table
It is possible to write custom data. To do this, the data should be passed to "put" method of "BwtTeam\LaravelRequestLogger\RequestLoggerRepository" class. For example:
app(\BwtTeam\LaravelRequestLogger\RepositoryInterface::class)->put('test', ['some', 'data']);
Alternatively, a facade could be used:
\RequestLogger::put('test', ['some', 'data']);
This package uses MIT.