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

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

pauloamgomes/logger
===================

Logger addon for Cockpit Headless CMS

1.2(7y ago)9953MITPHPPHP ^7.0

Since Sep 9Pushed 4y ago1 watchersCompare

[ Source](https://github.com/pauloamgomes/cockpit-logger-addon)[ Packagist](https://packagist.org/packages/pauloamgomes/logger)[ Docs](https://github.com/pauloamgomes/cockpit-cms-logger)[ RSS](/packages/pauloamgomes-logger/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Cockpit CMS Logger Addon
========================

[](#cockpit-cms-logger-addon)

This addon extends Cockpit CMS (Next) core by providing logging functionality based on the awesome [Monolog Library](https://github.com/Seldaek/monolog).

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

[](#installation)

Installation can be performed with ot without php composer.

### Without php composer

[](#without-php-composer)

1. Download zip and extract to 'your-cockpit-docroot/addons/Logger' (e.g. cockpitcms/addons/Logger)
2. Install Monolog dependency using composer

```
$ cd your-cockpit-docroot/addons/Logger
$ composer install
```

3. Access module settings `https://your-cockpit-site/settings/logger` and confirm that page loads.

### Using php composer

[](#using-php-composer)

1. Install addon using composer

```
$ cd your-cockpit-docroot/addons
$ composer create-project pauloamgomes/logger Logger
```

Configuration
-------------

[](#configuration)

The Logger operations are available to the super admin user, and they can be used by other users if they belong to a group with proper permissions. The following permissions are defined:

- *manage.admin* → Can access Logger settings

Above ACLs can be added to the global configuration file as below:

```
groups:
  # manage logger settings
  managers:
    Logger:
        manage.admin: true
  # view log entries
  editors:
    Logger:
        manage.view: true
```

### Main Settings

[](#main-settings)

The settings page provide all the main configurations:

[![Cockpit Logger settings page](https://camo.githubusercontent.com/543823100d67346f18bb94271aba3eb72784272be8bac5fde397fff0bb7383b4/68747470733a2f2f6d6f6e6f736e61702e636f6d2f696d6167652f6a34634b48673978624155357a6675306749697667654f304f7046675a77)](https://camo.githubusercontent.com/543823100d67346f18bb94271aba3eb72784272be8bac5fde397fff0bb7383b4/68747470733a2f2f6d6f6e6f736e61702e636f6d2f696d6167652f6a34634b48673978624155357a6675306749697667654f304f7046675a77)

1. **Enable** - Check that option to enable the logging
2. **Context attributes** - included in the logging entry as an extra array

    - Username - Includes the username of the active user
    - Hostname - Includes the hostname of the request
    - Request URI - Includes the request URI
    - Referrer - Includes the Referrer URI
    - HTTP Method - Includes the HTTP method of the request
3. **Log Level** - Set the log level

    Cockpit Logger uses the same log levels defined in Monolog:

    - DEBUG
    - INFO
    - NOTICE
    - WARNING
    - ERROR
    - CRITICAL
    - ALERT
    - EMERGENCY

    When its set to DEBUG, additional details about the request will be included in the log entry:

    - Duration time
    - Memory used
    - Number of loaded php files

### Monolog settings

[](#monolog-settings)

The Monolog sections are resumed to the Formatter and Handler.

#### Formatters

[](#formatters)

A formatter defines the structure of the log entries, Cockpit Logger supports three Monolog formatters

FormatterPurposeLineFormatterFormats a log record into a one-line string.JsonFormatterFormats a log record into jsonHtmlFormatterUsed to format log records into a human readable html table, mainly suitable for emails.Its also possible to define the format of the date in the log entries, the value must be a valid PHP date format like *Y-m-d H:i:s*

#### Handlers

[](#handlers)

A handler defines how the logs will be saved. Cockpit Logger provides two Handlers:

HandlerPurposeStreamHandlerSaves log entries in the filesystem using the configured location and filenameSyslogHandlerWrites the log entries using the operating system syslog functionality. Requires an ident and syslog facility.SyslogUdpHandlerPushes the log entries to a remove rsyslog server.The StreamHandler requires two additional settings:

- **Log Location** - Use either a relative location to the storage like "#storage:logs" or an absolute path like "/logs". In both cases ensure that web server can write on the target location
- **Log Filename** - The filename (e.g. cockpit.log)

The SyslogHandler requires also to additional settings:

- **Ident** - A string to identify the program name (e.g. cockpit)
- **Facility** - The Syslog Facility to use

#### Settings via config.yaml

[](#settings-via-configyaml)

Besides the configuration page the settings can also be defined in the cockpit config/config.yaml file, e.g.:

```
# Logger addon
logger:
  enabled: 1,
  level: INFO
  handler: StreamHandler
  formatter: LineFormatter
  context:
    user: 1
    hostname: 0
    http_method: 1
    referrer: 1
    request_uri: 1
```

When using the config.yaml, the settings will take precedence over the configuration page.

### Event Settings

[](#event-settings)

Most relevant Cockpit events (e.g. User login, Collection removal) are logged automatically:

- collections.save.after
- collections.remove.after
- collections.removecollection
- collections.createcollection
- collections.updatecollection
- regions.save.after
- regions.remove
- singleton.save.after
- singleton.saveData.after
- singleton.remove
- forms.save.after
- cockpit.assets.save
- cockpit.media.upload
- cockpit.media.removefiles
- cockpit.media.rename
- cockpit.assets.remove
- cockpit.authentication.success
- cockpit.authentication.failed
- cockpit.account.logout
- cockpit.clearcache
- cockpit.api.erroronrequest
- cockpit.request.error
- imagestyles.save.after
- imagestyles.createstyle
- imagestyles.remove

If required to disable, they can be disabled in the config.yaml, e.g:

```
logger:
  disabledEvents:
    - collections.save.after
    - collections.remove.after
```

### Examples

[](#examples)

- Saving a collection entry using **LineFormatter** and **NOTICE** level:

```
[2018-09-08 23:06:20] cockpit.NOTICE: Collection entry saved {"_id":"5aa5024609677doc2021128895","collection":"simpleblock","isUpdate":true,"user":"admin","hostname":"traefik_global.docker_default","request_uri":"/collections/save_entry/simpleblock","http_method":"POST"}
```

- Saving a collection entry using **LineFormatter** and **DEBUG** level:

```
[2018-09-08 23:06:46] cockpit.NOTICE: Collection entry saved {"_id":"5aa5024609677doc2021128895","collection":"simpleblock","isUpdate":true,"user":"admin","hostname":"traefik_global.docker_default","request_uri":"/collections/save_entry/simpleblock","http_method":"POST","debug":{"duration_time":"0.007 Sec","memory_usage":"2 MB","loaded_files":67}}
```

- Saving a collection entry using the **JsonFormatter** and **DEBUG** Level:

```
{
    "channel": "cockpit",
    "context": {
        "_id": "5aa5024609677doc2021128895",
        "collection": "simpleblock",
        "debug": {
            "duration_time": "0.008 Sec",
            "loaded_files": 67,
            "memory_usage": "2 MB"
        },
        "hostname": "traefik_global.docker_default",
        "http_method": "POST",
        "isUpdate": true,
        "request_uri": "/collections/save_entry/simpleblock",
        "user": "admin"
    },
    "datetime": {
        "date": "2018-09-08 23:09:10.434059",
        "timezone": "UTC",
        "timezone_type": 3
    },
    "extra": [],
    "level": 250,
    "level_name": "NOTICE",
    "message": "Collection entry saved"
}
```

- Saving a collection entry using the **HtmlFormatter** and **NOTICE** Level: [![HtmlFormatter Example](https://camo.githubusercontent.com/d850529d6fef6c23edbc7e96482538368b19664a380f2fabf0b0ec108e466dca/68747470733a2f2f6d6f6e6f736e61702e636f6d2f696d6167652f53325557524e56336b746c4f495748316f384436724253744554656f74392e706e67)](https://camo.githubusercontent.com/d850529d6fef6c23edbc7e96482538368b19664a380f2fabf0b0ec108e466dca/68747470733a2f2f6d6f6e6f736e61702e636f6d2f696d6167652f53325557524e56336b746c4f495748316f384436724253744554656f74392e706e67)

Logging on other addons using the Logger functions:
---------------------------------------------------

[](#logging-on-other-addons-using-the-logger-functions)

The Cockpit Logger can be used on any other code by just invoking the module, e.g.:

```
$this->app->module('logger')->info('writing a new log entry', ['hello' => 'world']);
$this->app->module('logger')->warning('something weird happened');
$this->app->module('logger')->error('something very wrong happened', ['error' => $e]);
```

Viewing the most recent logs in Cockpit
---------------------------------------

[](#viewing-the-most-recent-logs-in-cockpit)

Logs can be accessed on the server and processed using any tool, additionaly its also possible to access from the UI to the most recent log entries - `https://your-cockpit-site/recent-logs`.

[![Recent log messages](https://camo.githubusercontent.com/654eb8dcc897886f1d21741d4ae6d7d9bf040c5c308579fded6db72c2bb14f5a/68747470733a2f2f6d6f6e6f736e61702e636f6d2f696d6167652f486178444f57477a4f44467148524b73566c314756634a62414a655732522e706e67)](https://camo.githubusercontent.com/654eb8dcc897886f1d21741d4ae6d7d9bf040c5c308579fded6db72c2bb14f5a/68747470733a2f2f6d6f6e6f736e61702e636f6d2f696d6167652f486178444f57477a4f44467148524b73566c314756634a62414a655732522e706e67)

The UI supports automatic fetch and dynamic filters:

[![Recent log messages using filters](https://camo.githubusercontent.com/d128f470938c44d7c0addc41a0e548730f0dd0a612a15140d5ec584e2a7fcbc6/68747470733a2f2f6d6f6e6f736e61702e636f6d2f696d6167652f56374336783163586747676a3636425237334e5333437632614f6b6c76492e706e67)](https://camo.githubusercontent.com/d128f470938c44d7c0addc41a0e548730f0dd0a612a15140d5ec584e2a7fcbc6/68747470733a2f2f6d6f6e6f736e61702e636f6d2f696d6167652f56374336783163586747676a3636425237334e5333437632614f6b6c76492e706e67)

Security considerations
-----------------------

[](#security-considerations)

When using the StreamLogger and the log location is set to the `#storage:logs` ensure that file is not public accessible.

Copyright and license
---------------------

[](#copyright-and-license)

Copyright 2018 pauloamgomes under the MIT license.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 73.9% 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 ~32 days

Total

3

Last Release

2741d ago

### Community

Maintainers

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

---

Top Contributors

[![pauloamgomes](https://avatars.githubusercontent.com/u/102261?v=4)](https://github.com/pauloamgomes "pauloamgomes (17 commits)")[![raffaelj](https://avatars.githubusercontent.com/u/13042193?v=4)](https://github.com/raffaelj "raffaelj (4 commits)")[![abernh](https://avatars.githubusercontent.com/u/2691946?v=4)](https://github.com/abernh "abernh (2 commits)")

---

Tags

cockpit-cmscockpit-cms-addoncockpit-cms-loggingcockpit-logger-addonloggerloggingapiloggingcockpitcmsheadlessmonolog

### Embed Badge

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

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

###  Alternatives

[mero/yii2-monolog

The Monolog integration for the Yii framework.

42186.1k](/packages/mero-yii2-monolog)[naoray/laravel-github-monolog

Log driver to store logs as github issues

10619.4k](/packages/naoray-laravel-github-monolog)[jacklul/monolog-telegram

Monolog handler that sends logs through Telegram bot to any chat in HTML format

2364.7k1](/packages/jacklul-monolog-telegram)[shaffe/laravel-mail-log-channel

A package to support logging via email in Laravel

1286.2k](/packages/shaffe-laravel-mail-log-channel)[filips123/monolog-phpmailer

PHPMailer handler for Monolog

1365.6k3](/packages/filips123-monolog-phpmailer)

PHPackages © 2026

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