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

1.3.0(1y ago)1147.4k↓20.8%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 1mo ago

READMEChangelog (7)Dependencies (8)Versions (8)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

49

—

FairBetter than 95% of packages

Maintenance41

Moderate activity, may be stable

Popularity37

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity85

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 ~443 days

Recently: every ~546 days

Total

7

Last Release

487d ago

Major Versions

0.1.0 → 1.0.02018-08-28

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://www.gravatar.com/avatar/ec1a54f85a6e46909df4ca4852ada0cc4b1482f7208dfc487d05554087e09cc9?d=identicon)[thomasnordahl-dk](/maintainers/thomasnordahl-dk)

![](https://www.gravatar.com/avatar/9d0432f9ee26cc6265bcf3817d88bf40a4a8669a603785b34946e9c15d7b3451?d=identicon)[boan-jfm](/maintainers/boan-jfm)

![](https://www.gravatar.com/avatar/22799a8c3c482e408f78fd86a999b271f1d5fd2e04b433c6d199f717b3032bb2?d=identicon)[JyskFynskeMedierJoej](/maintainers/JyskFynskeMedierJoej)

![](https://www.gravatar.com/avatar/a974d9ad4b2be14736394ce117f53f83e9186e9cc05002bc004678f0b0587e37?d=identicon)[mifich](/maintainers/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

[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2322.9M248](/packages/open-telemetry-sdk)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)[neos/flow-development-collection

Flow packages in a joined repository for pull requests.

144179.3k3](/packages/neos-flow-development-collection)[pagemachine/typo3-formlog

Form log for TYPO3

23225.3k6](/packages/pagemachine-typo3-formlog)[rareloop/lumberjack-core

A powerful MVC framework for the modern WordPress developer. Write better, more expressive and easier to maintain code

42155.0k19](/packages/rareloop-lumberjack-core)

PHPackages © 2026

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