Looking to hire Laravel developers? Try LaraJobs

laravel-telegram-logging maintained by nvnhan0810

Description
Laravel log channel — send warnings/errors to Telegram with optional queue and message templates.
Author
nvnhan0810
Last update
2026/06/08 17:22 (dev-main)
License
Links
Downloads
0

Comments
comments powered by Disqus

laravel-telegram-logging

Laravel log channel that sends warning / error logs to Telegram.

Features

  • Configurable minimum log level (TELEGRAM_LOG_LEVEL)
  • Optional queue (TELEGRAM_LOG_QUEUE=true) — does not block HTTP requests
  • Custom HTML message template with placeholders ({%app_name%}, {%config:app.url%}, …)
  • Dedupe identical messages within a time window

Install

composer require nvnhan0810/laravel-telegram-logging

Or path repository (monorepo / local dev):

"repositories": [
    { "type": "path", "url": "../laravel-telegram-logging" }
],
"require": {
    "nvnhan0810/laravel-telegram-logging": "@dev"
}

Publish config (optional):

php artisan vendor:publish --tag=telegram-logging-config

Logging setup

In config/logging.php:

'telegram' => [
    'driver' => 'telegram-logging',
    'level' => env('TELEGRAM_LOG_LEVEL', 'warning'),
],

In .env:

LOG_STACK=daily,telegram

TELEGRAM_BOT_TOKEN=
TELEGRAM_CHAT_ID=
TELEGRAM_LOG_ENABLED=true
TELEGRAM_LOG_LEVEL=warning
TELEGRAM_LOG_QUEUE=false
# TELEGRAM_LOG_QUEUE_CONNECTION=
# TELEGRAM_LOG_QUEUE_NAME=

Test

php artisan telegram-log:test

Template placeholders

Placeholder Value
{%emoji%} Level emoji
{%level%} WARNING, ERROR, …
{%level_lower%} warning, error, …
{%message%} Log message (HTML escaped)
{%context%} Context JSON (escaped)
{%context_block%} <pre>…</pre> or empty
{%app_name%} config('app.name')
{%app_env%} config('app.env')
{%channel%} Log channel name
{%datetime%} ISO-8601 timestamp
{%config:app.url%} Any config('…') value

Override in config/telegram-logging.phptemplate.

Queue

When TELEGRAM_LOG_QUEUE=true, log records are dispatched to the default (or configured) queue. Run a worker:

php artisan queue:work

License

MIT