PHPackages                             simplecomplex/json-log - 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. simplecomplex/json-log

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

simplecomplex/json-log
======================

PSR-3 logger which files events as JSON.

1.5.2(7y ago)1176MITPHPPHP &gt;=7.0

Since Jul 12Pushed 6y ago2 watchersCompare

[ Source](https://github.com/simplecomplex/php-jsonlog)[ Packagist](https://packagist.org/packages/simplecomplex/json-log)[ Docs](https://github.com/simplecomplex/php-jsonlog)[ RSS](/packages/simplecomplex-json-log/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (2)Versions (15)Used By (0)

JsonLog
-------

[](#jsonlog)

PSR-3 logger which files events as JSON.

### Columns

[](#columns)

Columns are configuration-wise split in groups of *event*-, *request*- and *site*-specific items.
For every column there's a `JsonLogEvent` method and a JSON bucket name (this lists the bucket names).

Several columns get skipped if their equivalent method returns empty string (that's the un-bold items).

Some column's must be set via the PSR-3 logger methods' `$context` argument.

All column values are string, except the *code* column.

##### Event

[](#event)

- **message**
- **@timestamp**: ISO-8601
- **message\_id**: fairly random ID, using site ID as salt
- correlation\_id: set via `$context`
- **subtype**: set via `$context`, default `component`
- **level**: `emergency|alert|critical|error|warning|notice|info|debug`
- **code**: integer, set via `$context`; default `0`
- exception: PHP throwable, via `$context`; becomes class name
- trunc: `(original byte length/truncated length)`
- user: set via `$context`, or override `JsonLogEvent::user()` in extending class
- session: set via `$context`, override `JsonLogEvent::session()` in extending class

##### Request

[](#request)

- **method**: HTTP request method; `cli` if in CLI mode
- **request\_uri**: HTTP request URI; console arguments if in CLI mode
- referer: HTTP referrer (sanitized)
- client\_ip: remote address, filtered for *reverse\_proxy\_addresses*
- useragent: sanitized

##### Site

[](#site)

- **type**: *type* setting; default `webapp`
- **host**: `$_SERVER['SERVER_NAME']` or empty
- **site\_id**: *siteid* setting
- canonical: *canonical* setting
- tags: *tags* setting

### Settings

[](#settings)

Are set via 'global' [SimpleComplex Config](https://github.com/simplecomplex/php-config), section `lib_simplecomplex_jsonlog`.

The simplest approach to that is to **use environment variables**, like
`SetEnv lib_simplecomplex_jsonlog__threshold 7`.
`JsonLog` constructor uses environment variables as fallback.

- (int) **threshold**: less severe events are skipped (not logged); default `4` (~`warning`)
- (str) **siteid**: defaults to name of directory above document root
- (str) **path**: default `/var/log/[apache2|httpd|nginx]`/php-jsonlog
- (int) **truncate** (Kb): truncate *message* so that event JSON doesn't exceed that length; default `32`
- (str) **reverse\_proxy\_addresses**: comma-separated list of IP addresses; default empty
- (str) **type**: default `webapp`
- (str) **canonical**: site identifier across multiple instances; default empty
- (str) **tags**: comma-separated list; default empty
- (str) **reverse\_proxy\_header**: default `HTTP_X_FORWARDED_FOR`
- (str) **file\_time**: set to empty or `none` to write to the same log file forever; default `Ymd`
- (str) **format**: `default|pretty|prettier`; `prettier` is not valid JSON, but easier on the eyes

#### Recommended settings

[](#recommended-settings)

##### All environments

[](#all-environments)

- **siteid**: use something more meaningful than the default
- **truncate**: way higher, to like `256`, if your system generates giant dumps or traces

##### Prod environment

[](#prod-environment)

- **reverse\_proxy\_addresses**: look out for proxy servers

##### Dev/test environment

[](#devtest-environment)

- **threshold**: `7` (~`debug`)
- **path**: make it closer to home if no log extractor (like [Kibana+ElasticSearch](https://www.elastic.co)) running
- **format**: `prettier` if no log extractor running

### CLI commands

[](#cli-commands)

```
# List all json-log commands and their help.
php cli.php json-log -h
# One command's help.
php cli.php json-log-xxx -h

# Check/enable JsonLog to write logs.
php cli.php json-log-committable

# Truncate current log file.
php cli.php json-log-truncate
```

### Dependency injection container ID: logger

[](#dependency-injection-container-id-logger)

Recommendation: access (and thus instantiate) JsonLog via DI container ID 'logger'.
See [SimpleComplex Utils](https://github.com/simplecomplex/php-utils) `Dependency`.

### Requirements

[](#requirements)

- PHP &gt;=7.0
- [PSR-3 Log](https://github.com/php-fig/log)
- [SimpleComplex Utils](https://github.com/simplecomplex/php-utils)

##### Suggestions

[](#suggestions)

- [SimpleComplex Inspect](https://github.com/simplecomplex/inspect)
- [SimpleComplex Config](https://github.com/simplecomplex/php-config)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~52 days

Recently: every ~77 days

Total

13

Last Release

2594d ago

Major Versions

0.9 → 1.02017-09-24

### Community

Maintainers

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

---

Top Contributors

[![jacobfriis](https://avatars.githubusercontent.com/u/3807905?v=4)](https://github.com/jacobfriis "jacobfriis (123 commits)")

---

Tags

jsonloggerphpphp7psrpsr-3logpsr-3phpjson

### Embed Badge

![Health badge](/badges/simplecomplex-json-log/health.svg)

```
[![Health](https://phpackages.com/badges/simplecomplex-json-log/health.svg)](https://phpackages.com/packages/simplecomplex-json-log)
```

###  Alternatives

[markrogoyski/simplelog-php

Powerful PSR-3 logging. So easy, it's simple.

2818.1k4](/packages/markrogoyski-simplelog-php)[opengento/module-webapi-logger

This module allows you to analyze all the webapi rest done call toward your Magento.

1014.9k](/packages/opengento-module-webapi-logger)

PHPackages © 2026

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