royalcms/laravel-request-logger

HTTP request logger middleware for Laravel

1.3.0 2019-03-04 14:40 UTC

This package is auto-updated.

Last update: 2024-11-07 21:32:02 UTC


README

Request and Response Logger for Laravel

Installation

Composer

Add royalcms/laravel-request-logger to the "require" section of your composer.json file.

"royalcms/laravel-request-logger": "^1.4"

Run composer update to get the latest version of the package.

or

Run composer require royalcms/laravel-request-logger direct in your terminal

Laravel

In your config/app.php add Royalcms\Laravel\RequestLogger\RequestLoggerLoggerServiceProvider::class to the end of the providers array:

'providers' => array(
    ...,
    Royalcms\Laravel\RequestLogger\RequestLoggerLoggerServiceProvider::class,
),

Publish Configuration

php artisan vendor:publish --provider="Royalcms\Laravel\RequestLogger\RequestLoggerLoggerServiceProvider"

Configuration

In your config/request-logger.php file, you can change configuration for logger

'enabled'   => true,
'format' => 'default',
'log' => [
    'channel' => 'daily', //You can create a custom log channel
    'level' => 'info',
],
'exclude' => []

Format Interpolation

Variables

Default formats

Examples

{method} {full-url}

[2020-04-03 00:00:00] local.INFO: GET http://prettus.local/user/1?param=lorem ["REQUEST"]

{method} {full-url} {remote-addr} {port}

[2020-04-03 00:00:00] local.INFO: GET http://prettus.local/user/1?param=lorem 192.168.10.1 80 ["REQUEST"]

{method} {root} {url} {full-url} {path} {decoded-path} {remote-addr} {format} {scheme} {port} {query-string}

[2020-04-03 00:00:00] local.INFO: GET http://prettus.local http://prettus.local/user/1 http://prettus.local/user/1?param=lorem user/1 user/1 192.168.10.1 html http 80 param=lorem ["REQUEST"]

[{status}] HTTP:{http-version} {content}

[2020-04-03 00:00:00] local.INFO: [200] HTTP:1.1 {"id":1,"name":"Anderson Andrade", "email":"contato@andersonandra.de"} ["RESPONSE"]