PHPackages                             tankertrackers/laravel-telegram-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. tankertrackers/laravel-telegram-bot-logger

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

tankertrackers/laravel-telegram-bot-logger
==========================================

An easy-to-use wrapper around Telegram, allowing you to use it as a Log channel in Laravel.

v1.4.0(1y ago)12.4kMITPHPPHP ^8.2

Since Aug 22Pushed 1y ago1 watchersCompare

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

READMEChangelog (8)Dependencies (3)Versions (10)Used By (0)

laravel-telegram-bot-logger
===========================

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

> **Note** This was built under Laravel 10.x using PHP 8.1, so it has been locked to require at least those versions as I cannot guarantee functionality in previous versions of Laravel and/or PHP.

An easy-to-use wrapper around Telegram, allowing you to use it as a Monolog output channel in your Laravel applications. It does not require any dependencies not already in Laravel and there are no extra `config`files to worry about, allowing you to be up and running with this fairly quickly.

Note that this package is fairly opinionated in how it formats the output of the messages, but future versions will most likely introduce several ways to customize the output. In the current version, it outputs two or three rows, depending on if context is provided as the second input to your Log facade:

- Row 1: `[log level icon] [log level name] - [timestamp] - [app version]`
- Row 2: `[log message]`
- Row 3: `[context at JSON formatted string]`

Running the command `Log::warning('User failed password check.', ['user' => $user->id])` would result in the following message being sent to Telegram:

```
⚡️ WARNING - 2022-08-22 00:06:20 - 1.1.9
User failed password check.
{"user":718}

```

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

[](#installation)

### 1 - Adding the Package

[](#1---adding-the-package)

```
composer require tankertrackers/laravel-telegram-bot-logger
```

### 2 - Creating the Telegram Bot

[](#2---creating-the-telegram-bot)

This package requires you to create a Telegram bot, which will act as the sender of the log messages:

- Open a conversation with [`@BotFather`](https://t.me/BotFather) in Telegram.
- Send the message `/newbot` to begin creating a new bot.
- Set a name for your bot.
- Make a note of the `token`, as we will be using it later.
- Finally, open a private message with your bot and send a `/start` message to allow it to send messages to you.

### 3 - Updating your Logging Configuration

[](#3---updating-your-logging-configuration)

First, add the keys `TELEGRAM_BOT_TOKEN` and `TELEGRAM_CHANNEL` to your .env file:

```
TELEGRAM_BOT_TOKEN=123456789:ABCDEFGHIJ-abcdefghijklmnopqrstuv
TELEGRAM_CHANNEL=123456789
```

Note that `TELEGRAM_CHANNEL` can be either the ID of a user or a Telegram chat channel that you have invited the bot to. To get your own ID, open a chat with [`jsondumpbot`](https://t.me/jsondumpbot) and send it a `/start`command, and it will return to you your user's `id` value (under the key `message.chat.id`).

Getting the `id` for a Telegram chat channel seems to change every so often, so I recommend you Google for various solutions to this, as any suggestion given here might no longer be valid in a few weeks' time.

Then, include the following in your `config/logging.php`. Note that this will output messages of level `debug` and higher to Telegram when you are running your application in a non-production environment, but only `info` and higher when running in production. You are free to change these settings as you see fit, of course.

If the `level` key is not provided, it will default to `info` and higher.

```
  'telegram' => [
      'driver' => 'custom',
      'via' => \TankerTrackers\LaravelTelegramBotLogger\TelegramBotLogger::class,
      'token' => env('TELEGRAM_BOT_TOKEN'),
      'channel' => env('TELEGRAM_CHANNEL'),
      'level' => env('APP_ENV') === 'production' ? \Monolog\Level:Info : \Monolog\Level::Debug,
  ],
```

Once that is done, you can add `telegram` as a channel in your output stack at the top of `config/logging.php`:

```
  'stack' => [
      'driver' => 'stack',
      'channels' => ['single', 'telegram'],
  ],
```

Development
-----------

[](#development)

Development of this library is ongoing. Future versions will contain things like:

- Customizing the log output format, including:
    - Customizable DateTime formats.
    - Whether or not to include the app version.
    - Whether or not to include the log level icon.
    - Bringing the "metadata" inline with the "message" instead of posting it to a separate line.
    - Adding ability to display additional data based on the app environment.
- Add support for logging stacktraces in some way that doesn't look terrible.
- Allowing for easier setup of multiple outputs.
    - For example: Debug-messages **only** are sent to one channel, with everything else going to another channel.

Credits
-------

[](#credits)

No package exists in a vacuum, and with there already being plenty of Monolog wrappers around Telegram, I had plenty of inspiration from other places when making this package. Each of these packages did some things that I liked and other things that I didn't like, but reading them allowed me to better understand how best to write my own package. One of these may be well suited for your requirements if you feel that this package is too opinionated.

The packages I examined include, but are not limited to:

- [`grkamil/laravel-telegram-logging`](https://github.com/grkamil/laravel-telegram-logging)
- [`jacklul/monolog-telegram`](https://github.com/jacklul/monolog-telegram)
- [`kgatan/monolog-telegram`](https://github.com/kagatan/monolog-telegram)
- [`nechaienko/laravel-telegram-logging`](https://github.com/nechaienko/laravel-telegram-logging)
- [`rafaellaurindo/laravel-telegram-logging`](https://github.com/rafaellaurindo/laravel-telegram-logging)
- [`scary-layer/laravel-telegram-logging`](https://github.com/scary-layer/laravel-telegram-logging)
- [`thanhtaivtt/laravel-telegram-logger`](https://github.com/thanhtaivtt/laravel-telegram-logger)

Copyright
---------

[](#copyright)

This software is covered by the MIT License. See the file `LICENSE` for more information.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance46

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

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

Recently: every ~189 days

Total

8

Last Release

419d ago

PHP version history (2 changes)v1.0.0PHP ^8.1

v1.3.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/2005bc0510625184565d645acd62c9e54cbb1b692586276728e2293d2ce9b831?d=identicon)[Breki](/maintainers/Breki)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[illuminate/log

The Illuminate Log package.

6224.3M518](/packages/illuminate-log)[freshbitsweb/laravel-log-enhancer

Make debugging easier by adding more data to your laravel logs

346569.0k](/packages/freshbitsweb-laravel-log-enhancer)[marvinlabs/laravel-discord-logger

Logging to a discord channel in Laravel

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

Laravel 6.x/7.x/8.x/9.x/10.x/11.x/12.x/13.x bug notifier

299549.3k1](/packages/larabug-larabug)[honeybadger-io/honeybadger-laravel

Honeybadger Laravel integration

431.2M](/packages/honeybadger-io-honeybadger-laravel)

PHPackages © 2026

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