承接 marekmiklusek/telegram-logger 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

marekmiklusek/telegram-logger

Composer 安装命令:

composer require marekmiklusek/telegram-logger

包简介

A Laravel package to send logs to Telegram.

README 文档

README

blog-featured-how-to-delete-telegram

📢 Laravel Telegram Logger

🚀 Laravel Telegram Logger is a package that sends Laravel log messages and exceptions to Telegram for real-time monitoring.

📌 Features

Real-time logging to Telegram
Supports all log levels (debug, info, warning, error, etc.)
Automatic exception handling (captures error file, line, and message)
Configurable log level filtering
Silent notifications support (to avoid sound/vibration in Telegram)
Minimal setup, easy to integrate
Can be enabled/disabled via configuration

🛠 Installation

Require the package via Composer:

composer require marekmiklusek/telegram-logger

🔧 Configuration

Publish the package configuration:

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

This will create a config file at config/telegram-logger.php.

.env Configuration

Add your Telegram Bot API token and Chat ID to your .env file:

TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id

Config File (config/telegram-logger.php)

return [
    'bot_token' => env('TELEGRAM_BOT_TOKEN'),
    'chat_id' => env('TELEGRAM_CHAT_ID'),
    'level' => 'error',
    'silent_notification' => false,
    'is_enabled' => true,
];

🏗 Usage

Basic Logging

Use Laravel's Log facade as usual, and errors will be sent to Telegram automatically:

use Illuminate\Support\Facades\Log;

Log::debug('Debug message');
Log::info('Info message');
Log::warning('Warning message');
Log::error('Error message');

Logging with Context

You can pass additional context to logs:

Log::error('User not found', ['user_id' => 42, 'action' => 'login']);

Logging Exceptions

Exceptions are automatically detected and logged:

try {
    throw new \Exception('Database connection failed!');
} catch (\Exception $exception) {
    Log::error('Unhandled exception occurred', ['exception' => $exception]);
}

⚙ How It Works

The package listens to Laravel's logging events and sends structured messages to Telegram.

Example Telegram Log Output

🛠️ Application: MyLaravelApp
🌍 Environment: production

❌ Level: ERROR
📝 Message: "User not found"

📌 File:
/var/www/html/app/Http/Controllers/UserController.php:45

📂 Context:
{
  "user_id": 42,
  "action": "login"
}

⏳ Time: 2025-02-19 10:15:30

Example Telegram Log Output (Exception)

🛠️ Application: MyLaravelApp
🌍 Environment: production

❌ Level: ERROR
🔥 Exception Occurred !
💥 Message: "Database connection failed!"

📌 File:
/var/www/html/app/Services/DatabaseService.php:30

⏳ Time: 2025-02-19 10:18:45

🎯 Advanced Configuration

1️⃣ Logger Enablement

You can enable or disable the logger in config/telegram-logger.php:

return [
    'is_enabled' => false,
];

✅ If true, logs will be sent to Telegram as configured
✅ If false, the logger will be completely disabled (no logs sent)

2️⃣ Log Level Filtering

You can define the minimum log level in config/telegram-logger.php:

return [
    'level' => 'warning',
];
  • debug: Logs everything
  • info: Logs info, notice, warning, error, critical, alert, emergency
  • error: Logs error, critical, alert, emergency
  • critical: Logs only critical, alert, emergency

3️⃣ Silent Notifications

Enable silent notifications (no sound/vibration) in config/telegram-logger.php

return [
    'silent_notification' => true,
];

✅ If true, messages will be sent silently.
✅ If false, Telegram will send notifications normally.

💡 Troubleshooting

Logs not appearing in Telegram?

  1. Check that your .env values are correctly set:
php artisan config:clear
php artisan config:cache
  1. Ensure your bot has permission to send messages to your chat.

Getting "Chat not found" error?

  • Make sure you have sent a message to your bot first.
  • Use this tool to get your Chat ID.

📜 License

This package is open-source and licensed under the MIT License.

marekmiklusek/telegram-logger 适用场景与选型建议

marekmiklusek/telegram-logger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 714 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 02 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「package」 「php」 「logger」 「laravel」 「telegram」 「laravel-telegram-logger」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 marekmiklusek/telegram-logger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 marekmiklusek/telegram-logger 我们能提供哪些服务?
定制开发 / 二次开发

基于 marekmiklusek/telegram-logger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 714
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-19