PHPackages                             patrikap/laravel-api-logger - 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. patrikap/laravel-api-logger

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

patrikap/laravel-api-logger
===========================

A Laravel 5 package to log API requests

121PHP

Since Sep 5Pushed 6y ago1 watchersCompare

[ Source](https://github.com/patrikap/laravel-api-logger)[ Packagist](https://packagist.org/packages/patrikap/laravel-api-logger)[ RSS](/packages/patrikap-laravel-api-logger/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Log API requests
================

[](#log-api-requests)

Log API requests in Laravel applications

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

[](#installation)

You can install the package via composer:

```
composer require patrikap/laravel-api-logger
```

Optionally you can publish the configfile with:

```
php artisan vendor:publish --provider="Patrikap\ApiLogger\ApiLoggerServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

This packages provides a middleware which can be added as a global middleware or as a single route.

```
// in `app/Http/Kernel.php`

protected $middleware = [
    // ...

    \Patrikap\ApiLogger\Middlewares\ApiLogger::class
];
```

```
// in a routes file

Route::post('/submit-form', function () {
    //
})->middleware(\Patrikap\ApiLogger\Middlewares\ApiLogger::class);
```

### Logging

[](#logging)

Two classes are used to handle the logging of incoming requests: a `LogProfile` class will determine whether the request should be logged, and `LogWriter` class will write the request to a log.

A default log implementation is added within this package. It will only log `GET`, `POST`, `PUT`, `PATCH`, and `DELETE` requests and it will write to the default Laravel logger.

You're free to implement your own log profile and/or log writer classes, and configure it in `config/api-logger.php`.

A custom log profile must implement `\Patrikap\ApiLogger\LogProfile`. This interface requires you to implement `shouldLogRequest`.

```
// Example implementation from `\Patrikap\ApiLogger\DefaultLogProfile`

public function shouldLogRequest(Request $request): bool
{
   return in_array(strtolower($request->method()), config('api-logger.logged_methods'));
}
```

A custom log writer must implement `\Patrikap\ApiLogger\LogWriter`. This interface requires you to implement `logRequest` and `logResponse`.

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Author
======

[](#author)

[Patrikap](https://github.com/patrikap)

Inspiration
===========

[](#inspiration)

This project was inspired by the following projects:

- [Spatie HTTP Logger](https://github.com/spatie/laravel-http-logger)

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

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

---

Top Contributors

[![patrikap](https://avatars.githubusercontent.com/u/30617924?v=4)](https://github.com/patrikap "patrikap (3 commits)")

### Embed Badge

![Health badge](/badges/patrikap-laravel-api-logger/health.svg)

```
[![Health](https://phpackages.com/badges/patrikap-laravel-api-logger/health.svg)](https://phpackages.com/packages/patrikap-laravel-api-logger)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B9.2k](/packages/psr-log)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[graylog2/gelf-php

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

41838.2M138](/packages/graylog2-gelf-php)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[consolidation/log

Improved Psr-3 / Psr\\Log logger based on Symfony Console components.

15462.2M7](/packages/consolidation-log)[datadog/php-datadogstatsd

An extremely simple PHP datadogstatsd client

19124.6M15](/packages/datadog-php-datadogstatsd)

PHPackages © 2026

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