Download the PHP package dniccum/laravel-request-logs without Composer
On this page you can find all versions of the php package dniccum/laravel-request-logs. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dniccum/laravel-request-logs
More information about dniccum/laravel-request-logs
Files in dniccum/laravel-request-logs
Package laravel-request-logs
Short Description Log and debug HTTP requests within your Laravel application.
License MIT
Homepage https://github.com/dniccum/laravel-request-logs
Informations about the package laravel-request-logs
Laravel Request Logs
Provide insight to your application's requests with this Laravel-specific package. Simply add a light-weight middleware to your application and capture all the requests' body, headers, and responses. A console command is also provided that can be used to purge the logs to prevent any dated, unwanted bloat.
Installation
You can install the package via composer:
You can publish and run the migrations with:
You can publish the config file with:
This is the contents of the published config file:
Usage
Middleware
Adding to Middleware Groups
If you would like to use this package's middleware across a large group of requests, like all of your api
routes, you can apply it to your applications api middleware group within your app/Http/Kernel.php
like so:
Adding to specific routes
On the other hand, if you are wanting to add some logging clarity to specific routes, you can define it as a route middleware within your app/Http/Kernel.php
:
and then assign it to a specific route within your routes file:
IMPORTANT: Response Body Length Limit
Assuming that your database migration and model are unchanged, there is currently logic in place that will prevent the response_body
column from being overloaded. What does this mean? In the event that the response body of the request that you are logging is very large (ie returning 500+ results from an API), the number of bytes/characters might be too large for the database to store without failing. If the response body is longer than 65,000 characters, the response body will NOT be saved.
Log Cleanup (optional)
Note – this is not required but HIGHLY recommended as this could lead to large amounts of data within your database in short periods of time.
To automate the removal of older logs you can either use the provided artisan command php artisan request-logs:clean
manually with your app's environment, or you can leverage your app's scheduler process within your app/Console/Kernel.php
file to automate it like so:
Stored History
By default, this package will retain 21 days of logs. This can be changed via environment variable (LOGGING_HISTORY
) or simply modifying it within the request-logs.php
configuration file.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-request-logs with dependencies
laravel/framework Version ^8.0|^9.0|^10.0
spatie/laravel-package-tools Version ^1.13.0
illuminate/contracts Version ^9.0|^10.0