Download the PHP package eryndrix/exception-logger without Composer
On this page you can find all versions of the php package eryndrix/exception-logger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download eryndrix/exception-logger
More information about eryndrix/exception-logger
Files in eryndrix/exception-logger
Package exception-logger
Short Description Exception logging package for Laravel with PSR-3 levels and attribute-based configuration.
License MIT
Informations about the package exception-logger
Exception Logger
A Laravel package for structured exception logging with PSR-3 levels and attribute-based configuration. It allows you to define log levels per exception class using PHP attributes or configuration, and customize which exception details (stack trace, file, line, etc.) are included in logs based on severity.
Features
- PSR-3 compliant: Supports all 8 standard log levels (
debug,info,notice,warning,error,critical,alert,emergency) - Attribute-Based Configuration: Use
#[Log]attribute to define log level on exception classes - Configurable Context: Control which exception details to include in logs (exception class, code, file, line, trace)
- Level-Specific Context: Different context configuration for each log level
- Exception Level Mapping: Map exception classes to log levels via config
Installation
The service provider auto-registers. To publish the configuration file:
Requirements
- PHP ^8.5
- Laravel ^13.0
Quick Start
-
Use built-in exceptions
-
Or create your own
- Log exceptions
Inject ExceptionLoggerInterface and call log():
The logger resolves the level in this order:
#[Log]attribute on the exception classexception_levelsconfig mappingdefault_levelfallback
Logger Interface
For direct logging without level resolution, use LoggerInterface:
Configuration
The published config (config/exception-logger.php) has three sections:
default_level
Fallback level for exceptions without explicit configuration:
Tip: Use error in production, debug in development.
exception_levels
Map exception classes to levels without modifying them:
context
Control which details to include per log level:
Available fields:
| Field | Description |
|---|---|
exception |
Exception class name |
code |
Exception code (integer) |
file |
File where exception was thrown (full path) |
line |
Line number |
trace |
Full stack trace (can be very verbose) |
Security note: In production, disable file, line, and trace to avoid exposing internal paths.
Example Log Output
With the default config, a PaginationException produces:
Testing
Run package tests:
License
This project is licensed under the MIT License.