Laravel Request Logger provides a middleware that logs HTTP requests into a table.
It can be reconfigured to target specific requests or to log only specified informations.
For each request, the following informations are stored.
User
- session_id
- user_id
- ip
- route
- route_params: optional
Performances
- duration
- mem_alloc
HTTP stuff
- method
- status_code
- url: this one has 2 ways of configuration: set it to
fullto log full URL with query or set it totrueto log only URL - referer
- referer_host
- request_headers: optional
- response_headers: optional
Device
The following values are provided by the jenssegers/agent package.
- device
- os
- os_version
- browser
- browser_version
- is_desktop
- is_mobile
- is_tablet
- is_phone
- is_robot
- robot_name
- user_agent
Miscellaneous
- meta : this field is for custom logging. See RequestLogger::meta($value)
- created_at
Laravel Request Logger supports Laravel 6, 7, 8.
composer require landrok/laravel-request-logger
Create the request_logs table with
php artisan migrate
You may log every calls (default), only routes that match some patterns and only specified criterias.
You have to publish configuration file before.
php artisan vendor:publish --provider="Landrok\Laravel\RequestLogger\RequestLoggerServiceProvider"
The config file can be found at config/requestlogger.php.
This tool is made to log anything from anywhere in your code
(Controller, View, Service, etc...) into the meta column.
use Landrok\Laravel\RequestLogger\Meta;
Meta::set($key, $value);$value can be a string or an array or a serializable. It will be
stored as a JSON string.
Before using this method, you have to authorize this field in the config file.
Feel free to open issues and make PR. Contributions are welcome.
Laravel Request License is licensed under The MIT License (MIT).