PHPackages                             kodus/chrome-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. kodus/chrome-logger

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

kodus/chrome-logger
===================

PSR-3 (logging), PSR-7 (HTTP) and PSR-15 (middleware) compliant alternative to the original ChromeLogger for PHP

2.0.0(1w ago)1350.5k↓39%2[1 PRs](https://github.com/kodus/chrome-logger/pulls)MITPHPPHP &gt;=8.4

Since Oct 4Pushed 1y ago3 watchersCompare

[ Source](https://github.com/kodus/chrome-logger)[ Packagist](https://packagist.org/packages/kodus/chrome-logger)[ RSS](/packages/kodus-chrome-logger/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (8)Dependencies (16)Versions (9)Used By (0)

kodus/chrome-logger
===================

[](#koduschrome-logger)

[![PHP Version](https://camo.githubusercontent.com/487804500a039aee09e5d93e41b745b4cd68dcc0fdf801e67d26d30b93f83358/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e302532422d626c75652e737667)](https://packagist.org/packages/kodus/chrome-logger)[![Build Status](https://camo.githubusercontent.com/c0a753a57164214a684da41c8d0783dff39d42836af20223634a8d6267213ad5/68747470733a2f2f7472617669732d63692e6f72672f6b6f6475732f6368726f6d652d6c6f676765722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kodus/chrome-logger)[![Code Coverage](https://camo.githubusercontent.com/75fd99be2edc37876a5b76de87963c5e4715dc8442b1837c7437bb214916f6c6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b6f6475732f6368726f6d652d6c6f676765722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kodus/chrome-logger/?branch=master)

Alternative to the original [ChromeLogger](https://craig.is/writing/chrome-logger) for PHP by Craig Campbell, using:

- [PSR-3](http://www.php-fig.org/psr/psr-3/) compliant interface for logging,
- [PSR-7](http://www.php-fig.org/psr/psr-7/) HTTP message abstraction for the models, and
- [PSR-15](https://www.php-fig.org/psr/psr-15/) compliant middleware for quick integration.

✨ An alternative to the ChromeLogger extension [is also available](http://github.com/kodus/server-log)and is [highly recommended](#header-size-limit).

Usage
-----

[](#usage)

The logging interface is PSR-3 compliant, so:

```
$logger = new ChromeLogger();

$logger->notice("awesome sauce!");
```

Note that this will have a [header-size limit](#header-size-limit) by default.

Using a PSR-7 compliant `ResponseInterface` instance, such as in a middleware stack, you can populate the Response as follows:

```
$response = $logger->writeToResponse($response);
```

Or just add an instance of the included PSR-15 `ChromeLoggerMiddleware` to the top of your middleware stack.

If you're not using PSR-7, emitting the headers old-school is also possible with `ChromeLogger::emitHeader()`.

### Logging Table Data

[](#logging-table-data)

Since PSR-3 does not offer any explicit support for tables, we support tables via the context array.

For example:

```
$logger->info(
    "INFO",
    [
        "table: SQL Queries" => [
            ["time" => "10 msec", "sql" => "SELECT * FROM foo"],
            ["time" => "20 msec", "sql" => "SELECT * FROM baz"],
        ]
    ]
);
```

This works because the `"table:"` key prefix in the context array is recognized and treated specially.

### Logging a Stack Trace from an Exception

[](#logging-a-stack-trace-from-an-exception)

The reserved `"exception"` key in PSR-3 [context values](http://www.php-fig.org/psr/psr-3/#1-3-context) is supported - the following will result in a stack-trace:

```
try {
    something_dumb();
} catch (Exception $e) {
    $logger->error("ouch, this looks bad!", ["exception" => $e]);
}
```

Any PHP values injected via the context array will be serialized for client-side inspection - including complex object graphs and explicit serialization of problematic types like `Exception` and `DateTime`.

### Header Size Limit

[](#header-size-limit)

[Chrome has a 250KB header size limit](https://cs.chromium.org/chromium/src/net/http/http_stream_parser.h?q=ERR_RESPONSE_HEADERS_TOO_BIG&sq=package:chromium&dr=C&l=159)and many popular web-servers (including NGINX and Apache) also have a limit.

By default, the beginning of the log will be truncated to keep the header size under the limit.

You can change this limit using the `ChromeLogger::setLimit()` method - but a better approach is to enable logging to local files, which will persist in a web-accessible folder for 60 seconds:

```
$logger->usePersistence("/var/www/mysite/webroot/logs", "/logs");
```

Note that this isn't supported by the ChromeLogger extension - you will need to install the alternative [Server Log Chrome extension](http://github.com/kodus/server-log) instead. (It is backwards compatible with the header-format of the original ChromeLogger extension, so you can use this as a drop-in replacement for the original extension.)

Limitations
-----------

[](#limitations)

We do not currently support log-entry grouping, as supported by the original ChromeLogger for PHP, as this concept is not supported by PSR-3.

We do not make use of the reserved `'___class_name'` key used to color-code objects in ChromeLogger, because this does not work for nested object graphs - instead, we consistently indicate the object type as `type` in the console output, which works well enough, given that object properties are visually qualified with `$` prefix in the output. (Improving this in the future would require changes to the ChromeLogger extension.)

Why?
----

[](#why)

The original ChromeLogger for PHP has a static API, and aggressively emits headers, making it unsuitable for use in a [PSR-15](https://github.com/http-interop/http-middleware) based (or other) middleware stack. Static classes generally aren't much fun if you enjoy writing testable code.

This library also implements the PSR-3 `LoggerInterface`, which makes it easy to substitute this logger for any other.

Note that, while we aware of the `ChromePHPHandler` which comes with the popular logging framework [monolog](https://github.com/Seldaek/monolog/), `kodus/chrome-logger` has no external dependencies beyond the PSR interfaces, and uses `ResponseInterface::withHeader()` to populate PSR-7 Response objects, as opposed to making `header()` calls.

###  Health Score

56

—

FairBetter than 97% of packages

Maintenance65

Regular maintenance activity

Popularity37

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 86.4% 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 ~455 days

Recently: every ~674 days

Total

8

Last Release

10d ago

Major Versions

0.1.0 → 1.0.02018-08-28

1.3.0 → 2.0.02026-06-25

PHP version history (4 changes)0.1.0PHP &gt;=5.6

1.0.0PHP &gt;=7.0

1.2.0PHP &gt;=8.0

1.3.0PHP &gt;=8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5709900?v=4)[Thomas Nordahl Pedersen](/maintainers/thomasnordahl-dk)[@thomasnordahl-dk](https://github.com/thomasnordahl-dk)

![](https://avatars.githubusercontent.com/u/13201214?v=4)[Bo Andersen](/maintainers/boan-jfm)[@boan-jfm](https://github.com/boan-jfm)

![](https://avatars.githubusercontent.com/u/32329468?v=4)[Jesper Østergaard Jensen](/maintainers/JyskFynskeMedierJoej)[@JyskFynskeMedierJoej](https://github.com/JyskFynskeMedierJoej)

![](https://avatars.githubusercontent.com/u/25659854?v=4)[Michelle Fich](/maintainers/mifich)[@mifich](https://github.com/mifich)

---

Top Contributors

[![mindplay-dk](https://avatars.githubusercontent.com/u/103348?v=4)](https://github.com/mindplay-dk "mindplay-dk (19 commits)")[![boan-jfm](https://avatars.githubusercontent.com/u/13201214?v=4)](https://github.com/boan-jfm "boan-jfm (2 commits)")[![vortrixs](https://avatars.githubusercontent.com/u/15426116?v=4)](https://github.com/vortrixs "vortrixs (1 commits)")

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/kodus-chrome-logger/health.svg)

```
[![Health](https://phpackages.com/badges/kodus-chrome-logger/health.svg)](https://phpackages.com/packages/kodus-chrome-logger)
```

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[cakephp/cakephp

The CakePHP framework

8.9k19.5M1.8k](/packages/cakephp-cakephp)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[typo3/cms-core

TYPO3 CMS Core

3713.2M5.1k](/packages/typo3-cms-core)

PHPackages © 2026

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