PHPackages                             sajadjanat/laravel-mattermost-bot-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. sajadjanat/laravel-mattermost-bot-logger

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

sajadjanat/laravel-mattermost-bot-logger
========================================

A custom Laravel logging channel to send logs and exceptions to Mattermost using Bot Token (API v4)

v1.0.0(4mo ago)03MITPHPPHP ^8.1|^8.2|^8.3

Since Dec 17Pushed 4mo agoCompare

[ Source](https://github.com/sajadjanat/laravel-mattermost-bot-logger)[ Packagist](https://packagist.org/packages/sajadjanat/laravel-mattermost-bot-logger)[ RSS](/packages/sajadjanat-laravel-mattermost-bot-logger/feed)WikiDiscussions main Synced 1mo ago

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

Laravel Mattermost Bot Logger
=============================

[](#laravel-mattermost-bot-logger)

A custom logging channel for **Laravel** and **Lumen** that sends logs and exceptions directly to **Mattermost** using a **Bot Token** via the Mattermost API v4.

This package provides structured, readable log messages with severity indicators and full exception stack traces, making it suitable for production monitoring and error reporting.

**Keywords:** laravel logging, lumen logging, mattermost logger, mattermost bot, monolog handler, error monitoring

---

Features
--------

[](#features)

- Compatible with **Laravel 9, 10, 11+** and **Lumen 8, 9, 10+**
- Full support for **Monolog 3.x**
- Sends all log levels with severity-based formatting
- Detailed exception reporting including full stack trace
- Secure authentication via **Mattermost Bot Token**
- No external dependencies beyond the framework and Guzzle
- Simple `.env`-based configuration
- Works with both Laravel and Lumen without code duplication

---

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Laravel 9+ or Lumen 8+
- Mattermost Bot Account with Access Token

---

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

[](#installation)

```
composer require sajadjanat/laravel-mattermost-bot-logger
```

The package uses Composer autoloading and works out-of-the-box with both Laravel and Lumen.

---

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

[](#configuration)

### 1. Publish configuration (Laravel only – optional)

[](#1-publish-configuration-laravel-only--optional)

```
php artisan vendor:publish --tag=mattermost-logging-config
```

This will create:

config/logging-mattermost.php

> **Lumen note:** Lumen does not support vendor:publish. You can manually copy the configuration array into your logging setup.

---

### 2. Environment variables

[](#2-environment-variables)

Add the following to your .env file:

```
MATTERMOST_BASE_URL=https://your-mattermost-instance.com
MATTERMOST_BOT_TOKEN=your_bot_token_here
MATTERMOST_CHANNEL_ID=your_channel_id
MATTERMOST_BOT_USERNAME=Laravel/Lumen Errors
MATTERMOST_LOG_LEVEL=error
```

How to obtain values:

- Base URL: Your Mattermost server URL (without trailing slash)
- Bot Token: System Console → Integrations → Bot Accounts → Add Bot
- Channel ID: Channel menu → View Info → Copy Channel ID

---

### 3. Laravel logging channel setup

[](#3-laravel-logging-channel-setup)

In config/logging.php:

```
'channels' => [

    'mattermost' => config('logging-mattermost.mattermost'),

    'stack' => [
        'driver' => 'stack',
        'channels' => ['single', 'daily', 'mattermost'],
        'ignore_exceptions' => false,
    ],
];
```

Set default channel in .env:

```
LOG_CHANNEL=stack
```

---

### 4. Lumen setup (bootstrap/app.php)

[](#4-lumen-setup-bootstrapappphp)

```
$app->configure('logging');

$app->configureMonologUsing(function (Monolog\Logger $monolog) {
    $monolog->pushHandler(
        new \Sajadjanat\MattermostBotLogger\MattermostBotHandler(
            level: \Monolog\Logger::toMonologLevel(
                env('MATTERMOST_LOG_LEVEL', 'error')
            )
        )
    );

    return $monolog;
});
```

You may also use the handler manually via Log::channel('mattermost').

---

Manual Configuration Array
--------------------------

[](#manual-configuration-array)

If you prefer not to publish a config file, use the following channel definition:

```
'mattermost' => [
    'driver' => 'monolog',
    'handler' => \Sajadjanat\MattermostBotLogger\MattermostBotHandler::class,
    'level' => env('MATTERMOST_LOG_LEVEL', 'error'),
    'base_url' => env('MATTERMOST_BASE_URL'),
    'token' => env('MATTERMOST_BOT_TOKEN'),
    'channel_id' => env('MATTERMOST_CHANNEL_ID'),
    'bot_username' => env('MATTERMOST_BOT_USERNAME', 'Laravel/Lumen Bot'),
],
```

---

License
-------

[](#license)

MIT License

---

Contributing
------------

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first.

---

Made for the Laravel &amp; Lumen ecosystem.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance75

Regular maintenance activity

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

146d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/260bf0ee34070045771b0dc79a095e5c294fe3e879b09204d92f8a3658c2e03f?d=identicon)[sajadjanat](/maintainers/sajadjanat)

---

Top Contributors

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

---

Tags

laravelloggingexceptionsbotMattermost

### Embed Badge

![Health badge](/badges/sajadjanat-laravel-mattermost-bot-logger/health.svg)

```
[![Health](https://phpackages.com/badges/sajadjanat-laravel-mattermost-bot-logger/health.svg)](https://phpackages.com/packages/sajadjanat-laravel-mattermost-bot-logger)
```

###  Alternatives

[bugsnag/bugsnag-laravel

Official Bugsnag notifier for Laravel applications.

90234.6M36](/packages/bugsnag-bugsnag-laravel)[marvinlabs/laravel-discord-logger

Logging to a discord channel in Laravel

2081.1M2](/packages/marvinlabs-laravel-discord-logger)[ytake/laravel-fluent-logger

fluent logger for laravel and lumen

63541.6k1](/packages/ytake-laravel-fluent-logger)[shaffe/laravel-mail-log-channel

A package to support logging via email in Laravel

1286.2k](/packages/shaffe-laravel-mail-log-channel)

PHPackages © 2026

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