nvnhan0810/laravel-telegram-logging

Laravel log channel — send warnings/errors to Telegram with optional queue and message templates.

Maintainers

Package info

github.com/nvnhan0810/laravel-telegram-logging

pkg:composer/nvnhan0810/laravel-telegram-logging

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-08 15:22 UTC

This package is auto-updated.

Last update: 2026-06-08 15:48:03 UTC


README

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