PHP code example of marekmiklusek / telegram-logger
1. Go to this page and download the library: Download marekmiklusek/telegram-logger library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
marekmiklusek / telegram-logger example snippets
return [
'bot_token' => (string) env('TELEGRAM_BOT_TOKEN', ''),
'chat_id' => (string) env('TELEGRAM_CHAT_ID', ''),
'level' => (string) env('TELEGRAM_LOG_LEVEL', 'error'),
'silent_notification' => (bool) env('TELEGRAM_LOG_SILENT', false),
'is_enabled' => (bool) env('TELEGRAM_LOG_ENABLED', true),
'throw_on_failure' => (bool) env('TELEGRAM_LOG_THROW_ON_FAILURE', false),
'api_url' => (string) env('TELEGRAM_LOG_API_URL', 'https://api.telegram.org'),
'base_path' => base_path(),
'max_per_minute' => (int) env('TELEGRAM_LOG_MAX_PER_MINUTE', 20),
'dedupe_seconds' => (int) env('TELEGRAM_LOG_DEDUPE_SECONDS', 60),
'redact_keys' => ['password', 'secret', 'token', 'authorization', 'api_key', 'apikey', 'credit_card', 'cvv'],
];
use Illuminate\Support\Facades\Log;
Log::debug('Debug message');
Log::info('Info message');
Log::warning('Warning message');
Log::error('Error message');
Log::error('User not found', ['user_id' => 42, 'action' => 'login']);
try {
throw new \Exception('Database connection failed!');
} catch (\Exception $exception) {
Log::error('Unhandled exception occurred', ['exception' => $exception]);
}
return [
'is_enabled' => false,
];
return [
'level' => 'warning',
];
return [
'silent_notification' => true,
];
return [
'throw_on_failure' => false,
];
return [
'dedupe_seconds' => 60,
'max_per_minute' => 20,
];
Log::error('Login failed', ['email' => '[email protected] ', 'password' => 'hunter2']);
bash
php artisan vendor:publish --tag=telegram-logger-config
❌ ERROR | MyLaravelApp | production
User not found
📍 app/Http/Controllers/UserController.php:45
🕑 10:15:30
{
"user_id": 42,
"action": "login"
}
❌ ERROR | MyLaravelApp | production
Unhandled exception occurred
💥 PDOException
Database connection failed!
📍 app/Services/DatabaseService.php:30
🕑 10:18:45
bash
php artisan config:clear
php artisan config:cache