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

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

webiny/logger
=============

Webiny Logger Component

v1.6.1(8y ago)1153MITPHPPHP ^7

Since Sep 20Pushed 8y ago8 watchersCompare

[ Source](https://github.com/Webiny/Logger)[ Packagist](https://packagist.org/packages/webiny/logger)[ Docs](http://www.webiny.com/)[ RSS](/packages/webiny-logger/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (8)Versions (23)Used By (0)

Logger
======

[](#logger)

Logger component is used to log data. You can log whatever you want to whatever destination, all you need to do is create a `handler` for your logger driver. This component was heavily inspired by  library (if you used that one before, this component will be very familiar to you). You may say it's identical, but we found some things we wanted to change/improve, like having a `Record` class with proper getters/setters, we changed some method namings, processing logic and other bits and pieces to better suite our framework. We do lack different handlers, formatters and processors out-of-the-box, but that will come with time.

Install the component
---------------------

[](#install-the-component)

The best way to install the component is using Composer.

```
composer require webiny/logger
```

For additional versions of the package, visit the [Packagist page](https://packagist.org/packages/webiny/logger).

Drivers
-------

[](#drivers)

Built-in drivers are:

- `Null`
- `Webiny`

`Null` driver is used to turn off logging without changing your code. You simply change your configuration to use `Null` driver and all your logging calls will be sent into the void. `Webiny` driver contains most of the functionality you will ever need from a logger, so that driver is used by default.

Logger component uses PSR-3 Logger Interface and PSR-3 Log Levels. All log level constants are located in `LoggerLevel` class. With that being said, you can create your own logger driver, which will not even have handlers, formatters, processors, or anything like that. Just implement the logger interface and the rest is up to you. If you do like Monolog concept, then `Webiny` driver is the way to go.

Logger setup
------------

[](#logger-setup)

Here is an example logger service setup, which uses a `FileHandler`, two processors and a `FileFormatter`. The structure of the config file is identical to all other Webiny components that register services.

```
Logger:
    Parameters:
        Logger.Class: \Webiny\Component\Logger\Logger
        Logger.Driver.Class: \Webiny\Component\Logger\Driver\Webiny
        Logger.Processor.FileLine.Class: \Webiny\Component\Logger\Driver\Webiny\Processor\FileLineProcessor
        Logger.Processor.MemoryUsage.Class: \Webiny\Component\Logger\Driver\Webiny\Processor\MemoryUsageProcessor
        Logger.Formatter.File.Class: \Webiny\Component\Logger\Driver\Webiny\Formatter\FileFormatter
        Logger.Handlers.File.Class: \Webiny\Component\Logger\Driver\Webiny\Handler\FileHandler
    Services:
        MyFileLogger:
            Class: %Logger.Class%
            Arguments: [System, %Logger.Driver.Class%]
            Calls:
                - [addHandler, [@Logger.LogHandler]]
        LogFile:
            Class: \Webiny\Component\Storage\File\File
            Arguments:
                Key: Development/Log.txt
                Storage: @Storage.Logger # Define this service in your Storage configuration
        LogHandler:
            Class: %Logger.Handlers.File.Class%
            Arguments: [@Logger.LogFile, [], true, false]
            Calls:
                - [addProcessor, [%Logger.Processor.FileLine.Class%]]
                - [addProcessor, [%Logger.Processor.MemoryUsage.Class%]]
                - [setFormatter, [%Logger.Formatter.File.Class%]]
    Configs:
        Formatter:
            Default:
                DateFormat: 'H:i:s d-m-Y'
            File:
                RecordFormat: '%datetime% [%loggerName%] [%level%]: %message%\nContext: %context%\nExtra: %extra%\n\n'
    ClassLoader:
        Psr: '../Psr'
```

NOTE: `FileHandler` in our example (LogHandler service) takes a `File` as first argument. We can only write to files using `Storage` component, so we need a service which provides us with a `File` instance.

To use your logger in PHP:

```
// Set component config
Logger::setConfig($pathToYourConfigFile);

// Now your logger exists in the system as a 'MyFileLogger' service.
// You can use it by either using a LoggerTrait...
$logger = $this->logger('MyFileLogger');
$logger->info('This is pretty simple!');

// ... or by using ServiceManagerTrait. Note that ServiceManager groups services by component
// So your service is called 'Logger.MyFileLogger'. When using LoggerTrait, it appends the service group for you.
$logger = $this->service('Logger.MyFileLogger');
$logger->warn('This is just a little bit longer...');
```

The logic behind logger setup and log message processing
--------------------------------------------------------

[](#the-logic-behind-logger-setup-and-log-message-processing)

1. Create a logger instance
2. Create a handler instance(s) (you can have multiple handlers in your logger)
3. Add processors and formatters to your handler instance(s)
4. Add handler(s) to your logger
5. Use your logger

When you log a message, it goes through each handler, which in turn passes it to each processor. Formatter is the last thing to change a record. It simply formats the record into form that is appropriate for your handler. It may be string, array, etc. At the very end of processing - handler writes the formatted record to destination (be it file, database, email, socket, etc.)

Resources
---------

[](#resources)

To run unit tests, you need to use the following command:

```
$ cd path/to/Webiny/Component/Logger/
$ composer.phar install
$ phpunit

```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity73

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

Total

22

Last Release

3199d ago

PHP version history (3 changes)1.0.x-devPHP &gt;=5.4.0

v1.2.0PHP &gt;=5.5.9

1.5.x-devPHP ^7

### Community

Maintainers

![](https://www.gravatar.com/avatar/4440afa738ed146b05c06073a90345e0464c4f4d042b039532d881ca24859d77?d=identicon)[SvenAlHamad](/maintainers/SvenAlHamad)

---

Top Contributors

[![SvenAlHamad](https://avatars.githubusercontent.com/u/3808420?v=4)](https://github.com/SvenAlHamad "SvenAlHamad (26 commits)")

---

Tags

logpsr-3loggermonolog

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[inpsyde/wonolog

Monolog-based logging package for WordPress.

184637.3k7](/packages/inpsyde-wonolog)[analog/analog

Fast, flexible, easy PSR-3-compatible PHP logging package with dozens of handlers.

3511.6M24](/packages/analog-analog)[apix/log

Minimalist, thin and fast PSR-3 compliant (multi-bucket) logger.

521.1M20](/packages/apix-log)[bitrix-expert/monolog-adapter

Monolog adapter for Bitrix CMS

6566.7k](/packages/bitrix-expert-monolog-adapter)[pagemachine/typo3-formlog

Form log for TYPO3

23238.6k8](/packages/pagemachine-typo3-formlog)[markrogoyski/simplelog-php

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

2819.3k4](/packages/markrogoyski-simplelog-php)

PHPackages © 2026

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