- How do I install arhx/telegram-log-channel in Laravel?
- Run `composer require arhx/telegram-log-channel` to install. The package auto-registers its service provider, so no additional steps are needed beyond configuration.
- What Laravel versions does this package support?
- The package works with Laravel 10, 11, and 12. It requires PHP 8.0+. Older versions (e.g., Laravel 8/9) may need adjustments due to API changes.
- How do I configure the Telegram log channel?
- Add `TELEGRAM_LOG_BOT_TOKEN` and `TELEGRAM_LOG_CHAT_ID` to your `.env`, then include `'telegram'` in your `config/logging.php` stack. Example: `'channels' => ['daily', 'telegram']` for the default stack.
- What happens if my Telegram bot token or chat ID is missing?
- The package gracefully falls back to a `NullHandler`, meaning no logs are sent to Telegram, and your app won’t crash. This ensures zero downtime if credentials are misconfigured.
- Can I filter log levels (e.g., only send ERROR or CRITICAL logs)?
- Yes. Set `TELEGRAM_LOG_LEVEL` in your `.env` (e.g., `TELEGRAM_LOG_LEVEL=error`) or configure it in `config/logging.php` under the `telegram` channel. Defaults to `error` if unspecified.
- Does this package support automatic queue job failure alerts?
- Yes, it includes built-in queue job failure notifications. Enable or disable via `TELEGRAM_LOG_QUEUE_FAILURES` in `.env` (enabled by default). Each alert includes job class, exception, and queue connection details.
- Will this package work in production without issues?
- Yes, but monitor Telegram API rate limits if sending high-volume logs. Use `throw: true` in config to force errors if Telegram’s API fails, or rely on graceful fallback (default). Test in staging first.
- How do I customize the Telegram message format for logs?
- Extend the package by creating a custom Monolog processor or service provider. Override the default formatter in `config/logging.php` or use Laravel’s Monolog processors to modify log messages before they’re sent.
- Are there alternatives to this package for Telegram logging?
- Yes. Consider `spatie/laravel-telegram-channel` (similar functionality) or other alert channels like Slack (`spatie/laravel-slack-notification`) or PagerDuty. Choose based on your team’s preferred tooling.
- How do I test this package locally before deploying to production?
- Start by logging debug messages locally (`Log::debug('Test')`) and verify they appear in your Telegram chat. Use `TELEGRAM_LOG_LEVEL=debug` in `.env` for testing. Disable queue failure alerts (`TELEGRAM_LOG_QUEUE_FAILURES=false`) if not needed.