PHPackages                             tiny-blocks/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. tiny-blocks/logger

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

tiny-blocks/logger
==================

Emits PSR-3 structured logs for PHP, with correlation tracking and configurable sensitive data redaction.

2.0.0(1w ago)2255↓85.7%1MITPHPPHP ^8.5CI passing

Since Feb 21Pushed 4d agoCompare

[ Source](https://github.com/tiny-blocks/logger)[ Packagist](https://packagist.org/packages/tiny-blocks/logger)[ Docs](https://github.com/tiny-blocks/logger)[ RSS](/packages/tiny-blocks-logger/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (8)Dependencies (26)Versions (12)Used By (1)

Logger
======

[](#logger)

[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](https://github.com/tiny-blocks/logger/blob/main/LICENSE)

- [Overview](#overview)
- [Installation](#installation)
- [How to use](#how-to-use)
    - [Basic logging](#basic-logging)
    - [Correlation tracking](#correlation-tracking)
        - [At creation time](#at-creation-time)
        - [Derived from an existing logger](#derived-from-an-existing-logger)
    - [Sensitive data redaction](#sensitive-data-redaction)
        - [Document redaction](#document-redaction)
        - [Email redaction](#email-redaction)
        - [Phone redaction](#phone-redaction)
        - [Password redaction](#password-redaction)
        - [Name redaction](#name-redaction)
        - [Composing multiple redactions](#composing-multiple-redactions)
        - [Custom redaction](#custom-redaction)
    - [Custom log template](#custom-log-template)
- [License](#license)
- [Contributing](#contributing)

Overview
--------

[](#overview)

Emits PSR-3 structured logs for PHP, with each entry carrying timestamp, component, correlation id, level, and a structured data payload. Supports pluggable redactions for sensitive fields such as passwords, emails, phone numbers, and identity documents. Built for consumption by log aggregators and SIEM pipelines in production environments.

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

[](#installation)

```
composer require tiny-blocks/logger
```

How to use
----------

[](#how-to-use)

### Basic logging

[](#basic-logging)

Create a logger with `StructuredLogger::create()` and use the fluent builder to configure it. All PSR-3 log levels are supported: `debug`, `info`, `notice`, `warning`, `error`, `critical`, `alert`, and `emergency`.

```
