- How do I install marekmiklusek/telegram-logger in a Laravel application?
- Install it with composer require marekmiklusek/telegram-logger, then publish the configuration using php artisan vendor:publish --tag=telegram-logger-config. Add the bot token and chat ID to your .env file and declare a telegram channel in config/logging.php. There are no migrations, schema changes, or queue workers to set up, so adoption is purely configuration.
- Which PHP and Laravel versions does telegram-logger require?
- Version 2.x requires PHP 8.4 or newer and Laravel 13 or newer, and it depends only on illuminate/support and illuminate/contracts rather than the full framework package. If your application is still on PHP 8.2, 8.3, or Laravel 12, pin ^1.0 in composer.json so a routine composer update cannot pull in an incompatible release. Composer will normally resolve to 1.x automatically on older runtimes, so the 2.x line is mainly an alignment with your platform upgrade roadmap.
- How do I configure the Telegram bot token and chat ID?
- After publishing the config you provide the bot token, the target chat ID, and optionally the minimum log level, all through .env variables so secrets stay out of source control. The chat can be a private chat, group, or channel as long as the bot is a member and permitted to post messages. Every key added in 2.x falls back to a safe default, so an already published config file keeps working without edits.
- How do I actually send logs to Telegram from my code?
- Add the telegram channel to config/logging.php and then call Log::channel('telegram')->error($message) anywhere in your application. You can also attach it to a stack channel so high-severity events reach both your file or stdout handler and Telegram. The channel is additive, meaning it does not replace your existing log handlers.
- Do I have to change my existing Log::error() calls to use this package?
- No. The package registers itself as a Monolog handler behind a standard Laravel log channel, so existing Log::error(), Log::critical(), and other calls work unchanged. You only touch config/logging.php and .env, which means the adoption cost is configuration rather than refactoring application code.
- Can I limit which log levels get forwarded to Telegram?
- Yes. The channel accepts a minimum log level, and in 2.x that value is validated against PSR-3 at boot so a misconfiguration fails fast and loudly instead of silently sending nothing. Messages below the configured level are simply not forwarded to the chat. Setting the level to error or critical is the usual choice for production alerting.
- How do I test the Telegram log channel without spamming a production chat?
- Point the channel at a dedicated test bot and private test chat rather than your live on-call channel, then trigger it from php artisan tinker with a call such as Log::channel('telegram')->error('test'). Because the driver talks to the real Telegram Bot API, a separate test chat is the cleanest way to check message formatting. Keep the bot token in .env and never commit it.
- What happens if Telegram is down or rate-limits my messages?
- Delivery problems are contained inside the channel, so a Telegram outage does not throw back into your application code and the fixed v2 behaviour around malformed messages and missing config removes that availability risk. Optional dedupe_seconds and max_per_minute settings reduce flood risk, but they depend on a cache store and are skipped gracefully when no cache exists, which makes deduplication best effort. The Telegram Bot API also enforces its own rate budget per chat, so keep the channel for high-severity events.
- Is it safe to send Laravel logs to Telegram, and what about sensitive data?
- Log payloads leave your infrastructure and go to a third-party messaging platform, so treat the channel as a data egress point in your classification policy. Version 2.x redacts context by key name, which means unlisted values such as email addresses, order IDs, or free-text exception context can still be sent. For sensitive applications, restrict the channel to high-severity events and pass only an allow-listed set of context fields.
- How does telegram-logger compare to Sentry or a Slack logging channel?
- Compared with Sentry or Slack integrations, telegram-logger is a lightweight, low-cost alerting path that needs only a bot token and a chat ID, which suits small teams and internal tools where a full observability vendor is overkill. It is not an observability platform, so expect no error grouping, stack-trace dashboards, or log retention. Most teams run it as a second, high-severity channel alongside file, stdout, or Sentry logging rather than as the primary log sink.