Download the PHP package amirkateb/laralogger without Composer
On this page you can find all versions of the php package amirkateb/laralogger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download amirkateb/laralogger
More information about amirkateb/laralogger
Files in amirkateb/laralogger
Package laralogger
Short Description Advanced error logger for Laravel with AI analysis and Telegram/Email notifications.
License MIT
Informations about the package laralogger
Laralogger
Laralogger is a powerful, queue-ready Laravel error logging package that automatically captures HTTP 4xx/5xx errors and system-level issues, logs them to the database, sends customizable notifications (Telegram, Email), and even analyzes them using AI (GPT).
π Ω Ψ·Ψ§ΩΨΉΩ Ψ―Ψ§Ϊ©ΫΩΩ ΩΨͺ ΩΨ§Ψ±Ψ³Ϋ
π Features
- β Logs HTTP 4xx/5xx errors with full context
- β Stores logs in database (not files)
- β Smart notifications (Telegram, Email, or custom)
- β Optional AI error analysis via OpenAI (GPT-4/3.5)
- β Queue-supported (notifications & AI)
- β System log scanning (e.g. NGINX error log, 502s)
- β Artisan commands: simulate, cleanup, export, scan
- β
Fully configurable via
config/laralogger.php - β No UI β focused on automation and performance
π¦ Installation
βοΈ Configuration
Edit your config/laralogger.php to set:
activeβ enable/disableenvironmentsβ allowed environments (e.g. production, staging)log_status_codes,notify_status_codesβ define what gets logged and notifiednotificationsβ enable queue, channels, recipient email(s)aiβ OpenAI API key, model, and promptsystem_logs.nginxβ file path, match pattern, auto-store
You can also define a custom notification class via:
π£ Notification System
Laralogger supports sending error notifications via multiple channels such as Telegram, email, or custom handlers. Notifications are triggered after each error is logged.
π§ Configuration
In config/laralogger.php, define the channels and options:
π§© Built-in Notifiers
Laralogger\Notifications\TelegramNotifierLaralogger\Notifications\EmailNotifier
You can add your own class implementing Laralogger\Contracts\NotifiableInterface and plug it into the configuration.
π§ͺ Example
All notifiers support queue-based delivery if enabled.
π€ AI-Powered Error Analysis
Laralogger provides optional support for AI-driven error diagnostics using OpenAI (e.g. GPT-4 or GPT-3.5). When enabled, it automatically sends a summarized error context to the selected model and stores the response (suggested cause/fix) in your database.
π§ Enable AI Analysis
In config/laralogger.php, update the ai section:
Then, set the environment variable:
βοΈ The
promptsupports{{error}}as a placeholder that will be replaced with error details automatically.
π¦ Output
- The AI-generated explanation will be saved to the
ai_analysisfield in theerror_logstable. - If queue is enabled, analysis will be processed asynchronously.
- You can customize the
promptto fit your use-case or tone.
π§ͺ Example
Run this to test:
Check your database β you should see an AI-generated explanation added to the test log entry.
π§ͺ Artisan Commands
ποΈ Log Storage Structure
Laralogger stores all error logs in the database using the error_logs table. Each record includes detailed information about the exception, request, user, environment, and optional AI analysis.
π Schema Overview
By default, Laralogger creates the following columns in the error_logs table:
| Column | Description |
|---|---|
id |
Primary key |
message |
Exception message |
status_code |
HTTP status code (e.g., 404, 500) |
exception_class |
Class name of the exception |
file |
File path where exception occurred |
line |
Line number |
url |
Request URL |
method |
HTTP method (GET, POST...) |
user_id |
ID of authenticated user (nullable) |
user_type |
Guarded class (e.g., App\Models\User) |
headers |
Full request headers (JSON) |
payload |
Request body (JSON) |
ip |
Request IP address |
user_agent |
Userβs browser/device info |
ai_analysis |
Optional AI-generated explanation |
created_at |
Timestamp of the error |
π Migration
To publish and run the migration:
You can customize the migration to add extra columns if needed.
π§Ύ Log Schema
Each log entry contains:
- Status code
- Exception class & message
- Request method, URL, IP, headers, payload (optional)
- User ID, name, and guard (if logged in)
- AI analysis result (if enabled)
π Real-time Nginx Log Scanner
Laralogger can optionally monitor your Nginx error logs in real-time to catch server-level issues such as 502 Bad Gateway or 504 Gateway Timeout, even before they reach Laravel.
π§ Configuration
In config/laralogger.php:
βοΈ How It Works
- A background process (you can schedule it via cron or run as a systemd service) reads the last few lines of the Nginx error log.
- If any pattern matches (e.g., 502), it creates a new error log and sends notifications immediately.
π§ͺ Example Command
You may use this inside a scheduled task or create a background service like:
You can extend this to monitor multiple log files as well.
π Webhook Logging and Route Monitoring
Laralogger also supports optional logging of non-error HTTP requests such as:
- 2xx (Successful) responses
- 3xx (Redirects)
- Specific routes (e.g., payment gateways, webhooks)
This allows you to analyze traffic patterns, API behavior, or debug critical routes.
π§ Configuration
ποΈ Where Are They Logged?
These logs are stored in the same error_logs table, with a status_code like 200, 302, etc. They are marked with a non_exception flag internally to differentiate.
π Use Cases
- Payment debugging: Know what data was sent/received to/from gateways.
- Webhook tracing: Know exactly when and what payload came in.
- Traffic insights: Spot high-traffic or redirect-heavy endpoints.
π License
MIT Β© 2025 AmirMohammad KatebSaber