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

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

timatanga/logger
================

The timatanga Log package.

v0.1.0(4y ago)00MITPHPPHP ^8.0

Since Oct 2Pushed 4y ago1 watchersCompare

[ Source](https://github.com/timatanga/logger)[ Packagist](https://packagist.org/packages/timatanga/logger)[ RSS](/packages/timatanga-logger/feed)WikiDiscussions master Synced 1w ago

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

Logger
======

[](#logger)

To keep track what is going on in your application a logging service is very helpful. Depending on your needs you can write logs to files or send it to web services to notify your stackholders. This package utilizes the Monolog library and therefor implements the PSR-3 interface that you can type-hint against in your own libraries to keep a maximum of interoperability.

The logging is based on channels. Each channel can have it's own "log destination" or formatting depending on a log severity. It's possible to use different channels at one time to provide informations on different subjects.

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

[](#installation)

composer require timatanga/logger

Basic Configuration
-------------------

[](#basic-configuration)

The Logger packages ships with a logger configuration which you can use, extend or change upon your needs. It's housed in the config/logger.php configuration file and consists basically of two parts. The first part are basis logging configurations unrelated to any logging channels.

```
// config/logger.php

return [

    /**
     * Default logfile
     * If not explicitly set in a channel configuration the logfile is named like this
     */
    'logFile' => 'log',

    /**
     * Logfile directory
     * Filehandlers are writing logfiles to this relative location in regard to the root directory
     */
    'logPath' => 'storage/logs',

    /**
     * Logger Timezone
     * Overwrites default timezone which is UTC
     */
    'timezone' => 'Europe/Berlin',

    /**
     * Logging Dateformat
     * Logs are recorded in this datetime format
     */
    'dateFormat' => 'Y-m-d H:i:s',

    ...
]

```

Channel Configuration
---------------------

[](#channel-configuration)

The second part hosts the channel configurations. The configuration of logging channels follows a simple structure. A channel is identified by its key and requires at least a handler. All other arguments are optional. In the example below is a configuration for the channel "main"

```
// config/logger.php

return [

	....

    /**
     * Channels
     * Preconfigured log channels
     */
    'channels' => [

        'main' => [
            'handler' => RotatingFileHandler::class,
            'formatter' => LinePrettyFormatter::class,
            'processor' =>
            'config' => [
                'filename' => 'log',
                'maxFiles' => 10,
                'level' => env('LOG_LEVEL_MAIN', 'debug'),
            ]
        ],
	]
]

```

As mentioned earlier each channel needs at least a handler which can be one of the provided Monolog handlers, an extension of existing handlers or one of your own. A handler must implement the `Monolog\Handler\HandlerInterface` to get accepted.

Setting a formatter for a channel is considered optional. If no formatter is given the `Monolog\Formatter\LineFormatter` is set as default. If you wish to replace the formatter or build one of your one, please consider that is must implement the `Monolog\Formatter\FormatterInterface`.

With Processors Monolog transforms logging messages or integrates further datasets. Without explicitly set a processor for a channel, the `Monolog\Processor\PsrLogMessageProcessor`is appended to the handler instance. This processor has the ability to processes a log record’s message according to PSR-3 rules, replacing {foo} with the value from $context\['foo'\].

The config section of a channel configuration hosts the individual handler parameters. Each handler has it's own requirement when creating a new instance. Please consider the handler documentation or source code to get to know the according parameters.

Usage
-----

[](#usage)

Taking advantage of the logger package is easy and straightforward. First you need to create a new instance of the logger. The constructor accepts a single channel as a string or set of multiple channels as array argument

```
    $logger = new Logger('main');
    $logger = new Logger(['main', 'error', 'slack']);

```

When one of the requested channels is not provided in the configuration file you'll except an `timatanga\Logger\Exceptions\ResolveLoggerException` to be thrown.

Imagine circumstance where you cannot or are not willing to change the logger configuration but need a further logger channel and its configuration to get into play. To avoid an exception to be thrown, you may pass a custom channel configuration into the Logger constructor like so.

```
    $logger = new Logger(['main', extension'], ['extension' => ['handler' => RotatingFileHandler::class]]);

```

In the example above the channel "main" is registered as it's configuration is housed in the config/logger.php configuration file. Further the custom channel "extension" is registered while it's configuration is provided in the Logger constructor.

Sending log messages now very easy. You just need to mention the severity level with it's log message.

```
    $logger->info("just an info");

```

You may want to combine the log message with contextual data:

```
    $logger->info("just an info {key}", ['key' => 'message']);

    // will log: "just an info message"

```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

1689d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e85d042af6c9730c747e158b2b03e6876ebc03b3d2bdf5e3fe5e55fe4f6e6b2?d=identicon)[dbizapps](/maintainers/dbizapps)

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[rollbar/rollbar

Monitors errors and exceptions and reports them to Rollbar

33723.7M82](/packages/rollbar-rollbar)[illuminate/log

The Illuminate Log package.

6224.3M518](/packages/illuminate-log)[illuminated/console-logger

Logging and Notifications for Laravel Console Commands.

8674.9k](/packages/illuminated-console-logger)[alleyinteractive/logger

A Monolog-based logging tool for WordPress. Supports storing log message in a custom post type or in individual posts and terms.

30297.5k1](/packages/alleyinteractive-logger)

PHPackages © 2026

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