- How do I install laravel-telegram-logging?
- Install it with Composer by running composer require grkamil/laravel-telegram-logging in your Laravel project. Then publish or edit your config/logging.php file to add a dedicated Telegram channel and set the bot token and chat ID as environment variables. No database migrations or application domain changes are required.
- How do I configure a Telegram logging channel in Laravel?
- Add a new channel entry in config/logging.php that uses the package's Telegram driver, then supply the bot token and chat ID from your .env file. Keep it as a dedicated channel such as telegram_alerts and call it explicitly with Log::channel('telegram_alerts')->error(...) rather than attaching it to the default stack. This keeps noise and blast radius low.
- Which Laravel and Monolog versions does this package support?
- The package plugs into Laravel's Monolog-based logging channel system, so compatibility depends on your PHP, Laravel, and Monolog versions. Check the composer.json constraints and README before adopting, especially on older Laravel releases or Monolog v1/v2. If your stack is outside the supported range, a small custom Monolog handler may be safer.
- Can I send only errors and critical logs to Telegram?
- Yes. Set the channel's level threshold to error or higher, and route only the log calls you care about through Log::channel('telegram_alerts'). For incident alerting, error, critical, alert, and emergency are typical; avoid debug and info because they create noise and can hit Telegram rate limits. Selective routing also keeps sensitive low-value context out of chat.
- How do I create a Telegram bot and get a chat ID for logging?
- Create a bot with Telegram's BotFather, copy the bot token, and add the bot to a private team chat or channel. To get the chat ID, send a message in the chat and inspect getUpdates or use a helper bot that reports chat IDs. Store both values in your environment or secret manager, never in version control.
- How do I test Telegram logging without spamming my team chat?
- For a safe test, use a dedicated test chat with a separate bot token and set the channel level to debug only in your local environment. Send a single Log::channel('telegram_test')->info('test') message and confirm delivery, then switch back to error-level routing. This avoids spamming the real operations chat during development.
- What are Telegram rate limits and message length limits for logging?
- Telegram enforces per-chat and global rate limits and caps message length, so log storms, stack traces, and repeated exceptions can be throttled or truncated. Keep messages short and route only high-severity events to Telegram. If volume is high, batch or queue notifications and keep a file or centralized log as the full record.
- Does laravel-telegram-logging block requests or can it be queued?
- Monolog handlers are generally synchronous, so a Telegram API call can add latency to the request that emits the log. Use the channel selectively, keep it off the default stack, and consider queuing alerts or wrapping delivery so a Telegram outage cannot break application requests. The fallback should be your normal file, Slack, or centralized logging path.
- Is it safe to use Telegram logging in production?
- Treat Telegram as an alert sink, not a primary log transport. Logs often contain tokens, PII, SQL, headers, or customer data, so review what you send and restrict chat membership as a security control. Keep bot tokens and chat IDs in secret management and verify that failures are non-blocking.
- Is laravel-telegram-logging maintained, and what are the alternatives?
- The package has a small maintainer footprint, so pin a tested version and be prepared to fork it or replace it with a small custom Monolog handler. Alternatives include Laravel's built-in Slack channel, email or PagerDuty alerting, or a full observability backend. Whichever you choose, define a fallback for when Telegram is unavailable.