PHPackages                             akempes/laravel-request-logging - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. akempes/laravel-request-logging

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

akempes/laravel-request-logging
===============================

Write all incoming requests and there responses

2.1.5(7mo ago)64.4k↓50%2[5 PRs](https://github.com/akempes/laravel-request-logging/pulls)MITPHP

Since Feb 26Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/akempes/laravel-request-logging)[ Packagist](https://packagist.org/packages/akempes/laravel-request-logging)[ Docs](https://github.com/akempes/laravel-request-logging)[ RSS](/packages/akempes-laravel-request-logging/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)DependenciesVersions (19)Used By (0)

Request logging
===============

[](#request-logging)

[![Latest Stable Version](https://camo.githubusercontent.com/55066bc87c4b4d1ec8e25fe4a74b2552cc887ccde38cd68a5c41dff33e8a4d1c/68747470733a2f2f706f7365722e707567782e6f72672f616b656d7065732f6c61726176656c2d726571756573742d6c6f6767696e672f762f737461626c65)](https://packagist.org/packages/akempes/laravel-request-logging)[![Total Downloads](https://camo.githubusercontent.com/435e8a85dfb1dfc5b6db96cee3f08c257ddfed5b20dfb02fa42820b8ce757fad/68747470733a2f2f706f7365722e707567782e6f72672f616b656d7065732f6c61726176656c2d726571756573742d6c6f6767696e672f646f776e6c6f616473)](https://packagist.org/packages/akempes/laravel-request-logging)[![License](https://camo.githubusercontent.com/e5aa171849dc92c7a6db10b16dd2247f00cbb502d76cb2cd27370ebd63a96938/68747470733a2f2f706f7365722e707567782e6f72672f616b656d7065732f6c61726176656c2d726571756573742d6c6f6767696e672f6c6963656e7365)](https://packagist.org/packages/akempes/laravel-request-logging)

This Laravel package contains middleware to log requests and there responses including all parameters. This will allow you to monitor and replay requests which can be extremely helpful for debugging purposes.

Installation
------------

[](#installation)

You can install using [composer](https://getcomposer.org/) from [Packagist](https://packagist.org/packages/akempes/laravel-request-logging)

```
composer require akempes/laravel-request-logging

```

Next step is to add the middleware in your app/Http/Kernel.php file.

Add the request logging to all routes:

```
protected $middleware = [
    ...
    \Akempes\RequestLogging\LogRequest::class,
    ...
];

```

Or you only for specific route(group)s.

```
protected $routeMiddleware = [
    ...
    'logRequest' => \Akempes\RequestLogging\LogRequest::class,
    ...
];

```

Finally, although optionally, you can publish the configuration file:

```
php artisan vendor:publish --provider="Akempes\RequestLogging\RequestLoggingServiceProvider"

```

Upgrade Guide
-------------

[](#upgrade-guide)

### 1.x -&gt; 2.x

[](#1x---2x)

It shouldn't be hard, just run `php artisan vendor:publish --provider="Akempes\RequestLogging\RequestLoggingServiceProvider"` to get the new migration. Don't forget to run `php artisan migrate` as well.

Configuration
-------------

[](#configuration)

#### enabled

[](#enabled)

You probably guessed it already, the requests are logged when enabled is `true`. You can add `REQUEST_LOGGING_ENABLED` to your `.env` for maximal flexibility.

#### methods

[](#methods)

Array of the request methods you want to log.

#### exclude-routes

[](#exclude-routes)

Some routes may not need any logging. Enter the full path: `/first-segment/second-segment` under the hood Laravel `Request::is()` method is used.

#### exclude-request-fields

[](#exclude-request-fields)

Like the field `password`, some field may contain sensitive information and are not suitable for logging. These can be excluded from the logging.

#### request-duration-limit

[](#request-duration-limit)

You may want to log request that take a long time to complete. This can help you optimizing you application. Enter the maximum allowed duration in milliseconds or `false` to disable. Note: the request isn't aborted, just a extra log record is created. Also see: warning-log-channels &amp; warning-log-level below.

#### show-response-html

[](#show-response-html)

By default only the json response body is logged to prevent a log file full of HTML. But you can turn this feature off by setting it to `false`.

#### exclude-response-fields

[](#exclude-response-fields)

Actually the same as `exclude-request-fields`, some response data may contain sensitive information and are not suitable for logging.

#### log-channels

[](#log-channels)

You can specify where the logging should be put by adding the log channels as defined in you logging config. Multiple log channels are allowed.

#### log-level

[](#log-level)

By default the log level `info` is used but you are free to choose your own. (As of Laravel: Emergency, alert, critical, error, warning, notice, info, and debug.)

#### warning-log-channels

[](#warning-log-channels)

Same as log-channel except this channel will only be used for logs of requests exceeding the `request-duration-limit`.

#### warning-log-level

[](#warning-log-level)

Same as log-level except the default log-level is `warning`. This log level will only be used for logs of requests exceeding the `request-duration-limit`.

#### database-logging

[](#database-logging)

Besides logging to a file you may opt for logging to a database table.

*enabled*
Enable the database logging

*table*
The table name, default value is 'requests'.

*persistence*
Depending on your settings, application and traffic log files (and database) may consume a fair amount of storage data. To redress this issue, the logged requests are removed form the table after the set amount of days. Default value is 2 days.

*limit-response*
To prevent a huge database table you may want to limit the stored response data. Then setting this to a value &gt; 0 the data is truncated after the set amount of characters. The default value is 2000.

#### request-log-format

[](#request-log-format)

You are able to compose custom log messages using the variables as shown below.

VariableDescription*{microTimeStamp}*A very precise timestamp.*{requestId}*In order keep track of request and response, the last digits of the {microTimeStamp} are used as an ID. Although this ID is not unique, it is in general enough to separate multiple incoming requests.*{ip}*IP address.*{method}*HTTP method (GET, POST, PUT, ...)*{url}*Request path.*{requestBody}*All request data.*{files}*When documents are uploaded the filenames (and some metadata) are shown. Note: The content of the file is NOT logged.#### response-log-format

[](#response-log-format)

You are able to compose custom log messages using the variables as shown below.

VariableDescription*{microTimeStamp}*A very precise timestamp.*{requestId}*Has the same value as the `requestId` used in the request log message. This will help you finding the request belonging to this response.*{userId}*When the user is authenticated the id will be shown, empty otherwise.*{ip}*IP address.*{databaseId}*Shows the record ID when using database-logging. Note: The ID is not available in the request logging format. The log message is first send to the Log facade before an attempt is made to store the message it in the database.*{responseStatusCode}*HTTP status code to response.*{duration}*Duration between request and response in milliseconds.*{responseBody}*Data returned to client.*{targetUrl}*Empty by default. Contains the target url when the response is a redirect. (`responseStatusCode` in 300-series)*{isRedirecting}*Same as `{targetUrl}` but with 'Redirecting to' prefix. Default is still empty, only when the response is a redirect.

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance64

Regular maintenance activity

Popularity27

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 76.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~170 days

Recently: every ~218 days

Total

13

Last Release

220d ago

Major Versions

1.2.3 → 2.0.02023-05-11

### Community

Maintainers

![](https://www.gravatar.com/avatar/f48fa08531c7b233fd225e4b397e7bd475b8ebb5e106ad5b4c8d4732e0269e21?d=identicon)[akempes](/maintainers/akempes)

---

Top Contributors

[![akempes](https://avatars.githubusercontent.com/u/5055413?v=4)](https://github.com/akempes "akempes (16 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")

---

Tags

laravelloggingmonitoringrequesttimerrequestlaravellogging

### Embed Badge

![Health badge](/badges/akempes-laravel-request-logging/health.svg)

```
[![Health](https://phpackages.com/badges/akempes-laravel-request-logging/health.svg)](https://phpackages.com/packages/akempes-laravel-request-logging)
```

###  Alternatives

[ytake/laravel-fluent-logger

fluent logger for laravel and lumen

63541.6k1](/packages/ytake-laravel-fluent-logger)[kitloong/laravel-app-logger

Laravel log for your application

101.2M8](/packages/kitloong-laravel-app-logger)[shaffe/laravel-mail-log-channel

A package to support logging via email in Laravel

1286.2k](/packages/shaffe-laravel-mail-log-channel)[moesif/moesif-laravel

Moesif Collection/Data Ingestion Middleware for Laravel

1065.8k](/packages/moesif-moesif-laravel)[melihovv/laravel-log-viewer

A Laravel log viewer

1231.5k1](/packages/melihovv-laravel-log-viewer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
