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

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

schalkt/log
===========

Simple and easy configurable PHP logfile system

v2.2.0(3mo ago)1104MITPHPPHP ^8.2CI passing

Since Apr 8Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/schalkt/log)[ Packagist](https://packagist.org/packages/schalkt/log)[ RSS](/packages/schalkt-log/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (10)Dependencies (1)Versions (18)Used By (0)

Simple and easy configurable PHP log system
===========================================

[](#simple-and-easy-configurable-php-log-system)

A simple log system with pattern based path and messages. Objects and arrays are automatically converted to prettified JSON. You can also create CVS files. No need log rotation, just delete the older log folders if necessary.

[![Latest Stable Version](https://camo.githubusercontent.com/cb048ce454693e0d906d78b6f0cb6f92975ba18ca14b62230e6605cf6ba5ebff/68747470733a2f2f706f7365722e707567782e6f72672f736368616c6b742f6c6f672f76)](//packagist.org/packages/schalkt/log)[![Total Downloads](https://camo.githubusercontent.com/ce301c5c2b1ca6ed05bbe082ab8be15697613ef4f4c59ef9224c93260fd276e8/68747470733a2f2f706f7365722e707567782e6f72672f736368616c6b742f6c6f672f646f776e6c6f616473)](//packagist.org/packages/schalkt/log)[![PHP Version](https://camo.githubusercontent.com/a93dfc2794a2bc902e5601a679a068737089abd2c5ce9c155088734582e9af88/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736368616c6b742f6c6f672e737667)](https://packagist.org/packages/schalkt/log)[![License](https://camo.githubusercontent.com/268c89e635be2823eb2fbd851c817f2d7f265a6a7f0bfbee9aa5028f9e1c21b1/68747470733a2f2f706f7365722e707567782e6f72672f736368616c6b742f6c6f672f6c6963656e7365)](//packagist.org/packages/schalkt/log)[![GitHub issues](https://camo.githubusercontent.com/5bceee52e13856a127e68c4c5fbfa599215a51ce03b1e9c0c389ef73ac126dcf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f736368616c6b742f6c6f672e7376673f7374796c653d666c61742d737175617265)](https://github.com/schalkt/log/issues)[![Build](https://github.com/schalkt/log/actions/workflows/ci.yml/badge.svg)](https://github.com/schalkt/log/actions/workflows/ci.yml)[![GitHub stars](https://camo.githubusercontent.com/0293049708aad2d2f0b36c8dd9326f662969e46f5cc4e328b923f226393aca9c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f736368616c6b742f6c6f672e737667)](https://github.com/schalkt/log/stargazers)

Install
-------

[](#install)

- `composer require schalkt/log`

Features
--------

[](#features)

- pattern based logfile path: `/{TYPE}/{YEAR}/{YEAR}-{MONTH}/{TYPE}-{MONTH}-{DAY}`
- pattern based rows: `{DATE} | {STATUS} --- {MESSAGE}`
- objects and arrays converted to prettified JSON automatically
- customizable CSV row pattern: `'"{DATE}";{MESSAGE};"{BACKTRACE.CLASS}";"{BACKTRACE.FUNCTION}"'`
- logrotate not required due to the pattern-based log path
- multiple log types in config

Available log levels
--------------------

[](#available-log-levels)

- `Log::to()->info($message, $title = null);`
- `Log::to()->error($message, $title = null);`
- `Log::to()->critical($message, $title = null);`
- `Log::to()->warning($message, $title = null);`
- `Log::to()->notice($message, $title = null);`
- `Log::to()->debug($message, $title = null);`
- `Log::to()->exception(\Exception $ex, $title = null);`
- `Log::to('import')->error('Unique id required');`
- `Log::to('login')->notice($input, 'Invalid password');`

Examples
--------

[](#examples)

Example folder structure with {TYPE}, {YEAR}, {MONTH} and {DATE} patterns

```
/storage/logs
    - /default
        - 2021
        - 2022
    - /logins
        - /2021
        - /2022
            - /2022-09
            - /2022-10
                - /INFO-2022-10-20.log
                - /INFO-2022-10-21.log
                - /INFO-2022-10-22.log
                - /ERROR-2022-10-22.log
```

### Use default config

[](#use-default-config)

```
    use Schalkt\Slog\Log;

    require_once '/vendor/autoload.php';

    Log::to()->info('Hello World!');
```

### Change default log folder

[](#change-default-log-folder)

```
    use Schalkt\Slog\Log;

    require_once '/vendor/autoload.php';

    Log::default(["folder" => APP_PATH . '/storage/logs/default']);
    Log::to()->info('Hello World!');
```

### Add new config

[](#add-new-config)

```
    use Schalkt\Slog\Log;

    require_once '/vendor/autoload.php';

    Log::config('import', [
        'folder' => APP_PATH . '/storage/logs/import',
        'folder_chmod' => 0700,
        'pattern_row' => '{DATE} {EOL} {STATUS} {EOL} {MESSAGE} {EOL} {REQUEST}',
    ]);

    // add an error to the import log
    Log::to('import')->error('Unique id required');
```

### Load custom configs from file

[](#load-custom-configs-from-file)

```
    use Schalkt\Slog\Log;

    require_once '/vendor/autoload.php';

    // set config file path
    Log::configs('./config/logs.php');

    // add an error to the default log
    Log::to()->error('Password required');

    // add an input array to the login log with title
    Log::to('login')->notice($input, 'Invalid password');
```

Configs
-------

[](#configs)

### Default config

[](#default-config)

```
return [
    'default' => [
        "folder" => APP_PATH . '/storage/logs/default',
        "folder_chmod" => 0770,
        "pattern_file" => "/{YEAR}-{MONTH}/{TYPE}-{YEAR}-{MONTH}-{DAY}",
        "pattern_row" => "{DATE} | {STATUS} --- {MESSAGE}",
        "extension" => "log",
        "format_date" => 'Y-m-d H:i:s',
    ]
];
```

### Custom config file

[](#custom-config-file)

```
return [
    "csv" => [
        "folder" =>  APP_PATH . '/storage/logs/csv',
        "header" => '"date";"message";"class";"function"',
        "pattern_file" => "/{TYPE}/{YEAR}-{MONTH}/{TYPE}-{YEAR}-{MONTH}-{DAY}",
        "pattern_row" => '"{DATE}";{MESSAGE};"{BACKTRACE.CLASS}";"{BACKTRACE.FUNCTION}"',
        "extension" => "csv",
    ],
    "login" => [
        "folder" => APP_PATH . '/storage/logs/login',
        "pattern_file" => "/logins/{TYPE}/{YEAR}-{MONTH}-{DAY}",
        "pattern_row" => "{DATE} {TITLE} {MESSAGE}",
    ],
];
```

Available variables in patterns
-------------------------------

[](#available-variables-in-patterns)

- `{MESSAGE}` &lt;- first parameter of function (required, string, array, object, any)
- `{TITLE}` &lt;- second parameter of function (not required, string or number)
- `{TYPE}` &lt;- came from log config
- `{STATUS}` &lt;- info, error, critical, warning, notice, debug, or exception
- `{REQUEST}` &lt;- dump $\_REQUEST
- `{RAWBODY}` &lt;- file\_get\_contents('php://input')
- `{EOL}` &lt;- PHP\_EOL
- `{DATE}` &lt;- date by config "format\_date", default "Y-m-d H:i:s"
- `{YEAR}` &lt;- date('Y')
- `{MONTH}` &lt;- date('m')
- `{DAY}` &lt;- date('d')
- `{HOUR}` &lt;- date('H')
- `{MIN}` &lt;- date('i')
- `{IP}`: Client's IP address.
- `{USER_AGENT}`: User's browser user agent.
- `{REQUEST_METHOD}`: HTTP request method (e.g., GET, POST).
- `{REQUEST_URI}`: The requested URI.
- `{SESSION_ID}`: Current session ID.
- `{HOSTNAME}`: Server's hostname.
- `{EXECUTION_TIME}`: Script execution time.
- `{MEMORY_USAGE}`: Current memory usage.
- `{MEMORY_PEAK_USAGE}`: Peak memory usage.

### Flush Logs

[](#flush-logs)

The `flush` method allows you to delete all log files under a specific log type's folder. By default, it also deletes the base folder. However, you can control this behavior by passing a boolean parameter to the method.

#### Usage

[](#usage)

```
// Delete all log files and the base folder
Log::to('custom')->flush();

// Delete only the log files but keep the base folder
Log::to('custom')->flush(false);
```

If the folder is protected (e.g., root directories like `./` or `../`), the method will throw a `LogException` to prevent accidental deletion.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance79

Regular maintenance activity

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity77

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

Recently: every ~240 days

Total

17

Last Release

109d ago

Major Versions

1.2.1 → 2.0.02021-03-15

PHP version history (6 changes)1.0.0PHP &gt;=5.4.0

1.1.0PHP &gt;=7.3.0

2.0.1PHP &gt;=7.2.0

2.0.3PHP &gt;=7.4.0

2.1.2PHP 8.\*

v2.2.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![schalkt](https://avatars.githubusercontent.com/u/4790264?v=4)](https://github.com/schalkt "schalkt (1 commits)")

---

Tags

logloggerphplogphpSimpleeasyconfigurable

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[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)
