PHPackages                             ampersand/magento2-verbose-log-request - 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. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. ampersand/magento2-verbose-log-request

ActiveMagento2-component[Debugging &amp; Profiling](/categories/debugging)

ampersand/magento2-verbose-log-request
======================================

Enable DB, debug log, and verbose logging for a specificly defined request.

1.2.1(2mo ago)19492[1 issues](https://github.com/idhlagency/magento2-verbose-log-request/issues)PHPPHP ^7.4||^8.1

Since Oct 20Pushed 2mo ago5 watchersCompare

[ Source](https://github.com/idhlagency/magento2-verbose-log-request)[ Packagist](https://packagist.org/packages/ampersand/magento2-verbose-log-request)[ RSS](/packages/ampersand-magento2-verbose-log-request/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (20)Versions (8)Used By (0)

magento2-verbose-log-request
============================

[](#magento2-verbose-log-request)

[![Build Status](https://camo.githubusercontent.com/990f56896a69fd9947828be54d62d745dde5ebaa57f319ece5aadba72a6ef556/68747470733a2f2f7472617669732d63692e636f6d2f416d70657273616e6448512f6d6167656e746f322d766572626f73652d6c6f672d726571756573742e7376673f746f6b656e3d34447a6a457565594e51775a756b337977586a47266272616e63683d6d6173746572)](https://app.travis-ci.com/AmpersandHQ/magento2-verbose-log-request)

Summary
-------

[](#summary)

Dynamically change the [log level per request](https://devopedia.org/log-level-per-request) to `DEBUG`. This enables database, debug log, and verbose logging for a specifically defined request.

Pass in a `X-Verbose-Log` header and Magento will activate the kind of logging you usually only have in developer mode for that request.

This means you can get verbose information when you are debugging something on production without having to switch on these settings forcefully. This is beneficial as on high traffic sites this can produce a lot of log data and narrowing in for what you are interested in can be difficult otherwise.

It is recommended that you also install [ampersand/magento2-log-correlation-id](https://github.com/AmpersandHQ/magento2-log-correlation-id/) to help correlate your log entries together.

Compatible with Magento 2.4.1 and higher.

Features
--------

[](#features)

- Database query (and stack trace) logging will be enabled and output to `./var/log/verbose_db.log`
    -
    - See `src/Logger/DB/LoggerProxy.php`
- Magento `debug` logging usually requires that you set a flag and flush a cache, we can pass the flag to activate it for your specific requests without these steps
    -
    - See `src/Logger/Handler/Debug.php`
- Bundled in this module is a cache decorator which will add to the vanilla offering of logging `cache_invalidate` with `cache_load` and `cache_save` information.
    - This uses a virtual type `Ampersand\VerboseLogRequest\Logger\VerboseDebugLogger` which calls to `->debug()` on the `Psr\Log\LoggerInterface`.
    - See `src/CacheDecorator/VerboseLogger.php`
- Set redis session log level to debug mode (level 7)
    - Allows you to see redis lock acquisitions, lock waits, zombie processes, etc
    - [https://github.com/colinmollenhour/Cm\_RedisSession#configuration-example](https://github.com/colinmollenhour/Cm_RedisSession#configuration-example)

Example Usage
-------------

[](#example-usage)

On the system you want to debug run the following command to get the current key

```
$ php bin/magento ampersand:verbose-log-request:get-key
The current key is:               d07c0ee76154d48c2974516ef22c1ec0
The current key will expire at:   2022-10-25 09:00:00

```

Make a request to your desired page with an `X-Verbose-Log` header set to that value

```
curl -H "X-Verbose-Log: d07c0ee76154d48c2974516ef22c1ec0" https://example.com/your-page/
```

or

```
X_VERBOSE_LOG=d07c0ee76154d48c2974516ef22c1ec0 php bin/magento some:command:here

```

See all your verbose log files

```
 12M var/log/debug.log
3.1M var/log/verbose_db.log
4.0K var/log/system.log
4.0K var/log/support_report.log
```

If you want to do more complex interactions you could use something like [modheader](https://chrome.google.com/webstore/detail/modheader/idgpnmonknjnojddfkpgkljpfnnfcklj?hl=en) to set this value for a series of requests, be aware that will output a LOT of debug data.

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

[](#installation)

Composer require the module.

```
composer require ampersand/magento2-verbose-log-request

```

Run module installation, this will generate your `ampersand/verbose_log_request/key` in `app/etc/config.php`, commit this change.

```
php bin/magento setup:upgrade

```

Update your `.gitignore` to ignore

```
app/etc/di.xml_ampersand_magento2_verbose_log_request/di.xml

```

If you want to give certain admin users permissions to get the key via the `Admin Panel -> Account Settings -> Get Verbose Log Key` create `app/etc/di.xml_ampersand_magento2_verbose_log_request/allowed_emails_di.xml` and define the allowed emails/domains.

```

                example@firstexample.com

                secondexample.com

```

Security considerations
-----------------------

[](#security-considerations)

As all we are doing is writing to the log files the biggest "risk" is to your disk space.

However as you need to know the key to trigger the logging it can be locked down to your developers and won't be accessible to the outside world unless they already have access to your file system.

A log level below "debug", the VerboseDebugLogger
-------------------------------------------------

[](#a-log-level-below-debug-the-verbosedebuglogger)

By default magento has `debug` level logging enabled on `developer` mode and it may even be activated on some production environments. As we want to log `cache_load` and `cache_save` information this would rapidly fill up your log files on either your developer machine, or those production enivornments with lots of unnecessary data.

To ensure we only trigger these *extra verbose* debug level logging when the `X-Verbose-Log` request is flagged, we have a virtual type that you can inject into your classes.

`Ampersand\VerboseLogRequest\Logger\VerboseDebugLogger` will write to the `./var/log/debug.log` file the same as the standard calls to `->debug()`, but they will only write when flagged to in the request.

In this manner we can spoof in a sort of log level below `DEBUG` as defined in [RFC 5424](https://www.rfc-editor.org/rfc/rfc5424). It is still a debug log, but it is only triggered when specifically requested and is therefore a bit separate from standard debug logs.

You can tell your class to use this kind of debug logging by injecting it in place of the standard `\Psr\Log\LoggerInterface` by defining a `di.xml` like so

```

        Ampersand\VerboseLogRequest\Logger\VerboseDebugLogger

```

### It's great for adding hotfix logging

[](#its-great-for-adding-hotfix-logging)

We all hope that it is never necessary but if you ever feel the need to add some hotfix logging onto an environment you can improve it by using the `VerboseDebugLogger`

Inject that dependency (as described above) and you can put debug statements all through your application that will only trigger when you request it on the problematic environment.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance86

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 95.8% 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 ~247 days

Recently: every ~307 days

Total

6

Last Release

65d ago

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/248c125feb1acc5c8932c06226dcd5086760736ff5fc9ec69be32a3aeae8a339?d=identicon)[chickenland](/maintainers/chickenland)

---

Top Contributors

[![convenient](https://avatars.githubusercontent.com/u/600190?v=4)](https://github.com/convenient "convenient (23 commits)")[![ahasAmp](https://avatars.githubusercontent.com/u/43336207?v=4)](https://github.com/ahasAmp "ahasAmp (1 commits)")

---

Tags

debuggingdebugging-toollog-levelmagentomagento2

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ampersand-magento2-verbose-log-request/health.svg)

```
[![Health](https://phpackages.com/badges/ampersand-magento2-verbose-log-request/health.svg)](https://phpackages.com/packages/ampersand-magento2-verbose-log-request)
```

###  Alternatives

[smile/elasticsuite

Magento 2 merchandising and search engine built on ElasticSearch

8044.5M33](/packages/smile-elasticsuite)[smile/module-debug-toolbar

Smile Debug Toolbar

146247.6k2](/packages/smile-module-debug-toolbar)[yireo/magento2-whoops

Magento 2 module adding Whoops error handling

102703.5k](/packages/yireo-magento2-whoops)[clawrock/magento2-debug

Magento 2 debug module based on Magento 1 Profiler with some extra features.

8419.3k1](/packages/clawrock-magento2-debug)[graycore/magento2-stdlogging

A Magento 2 module that changes all logging handlers to stdout

2382.6k](/packages/graycore-magento2-stdlogging)

PHPackages © 2026

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