Appearance
Logging
Table of Contents
Overview
Phenix uses Monolog for application logs and exposes a Log facade for writing PSR-3 log messages.
The default logging channel is configured with LOG_CHANNEL. The minimum level written by the logger is configured with APP_DEBUG_LEVEL.
Writing Logs
Use the Log facade from application code:
php
use Phenix\Facades\Log;
Log::debug('Loading profile {id}', ['id' => $userId]);
Log::info('User signed in', ['id' => $userId]);
Log::warning('External service responded slowly', ['service' => 'billing']);
Log::error('Payment failed', ['order_id' => $orderId]);The context array is processed by Monolog, so placeholders in the message can be replaced by matching context values.
Channels
Phenix ships two logging channels:
| Channel | Description |
|---|---|
file | Writes logs to the configured log file. |
stream | Writes logs to stdout. |
Set the channel in your environment:
dotenv
LOG_CHANNEL=fileUse stream when the process manager, container runtime, or platform collects stdout:
dotenv
LOG_CHANNEL=streamLog Level
APP_DEBUG_LEVEL controls the minimum Monolog level that will be written. Lower severity records are ignored.
| Value | Level | Typical use |
|---|---|---|
100 | debug | Detailed local diagnostics. |
200 | info | Normal production events. |
250 | notice | Uncommon but expected events. |
300 | warning | Problems that do not stop the request. |
400 | error | Runtime errors that should be investigated. |
500 | critical | Critical application failures. |
550 | alert | Immediate action required. |
600 | emergency | The application is unusable. |
For local development, keep debug logs enabled:
dotenv
APP_DEBUG=true
APP_DEBUG_LEVEL=100For production, start with info logs:
dotenv
APP_DEBUG=false
APP_DEBUG_LEVEL=200Applications with high traffic or very noisy logs can raise the value to 300 or 400.
Environment Examples
Local development:
dotenv
APP_ENV=local
APP_DEBUG=true
APP_DEBUG_LEVEL=100
LOG_CHANNEL=fileContainer production:
dotenv
APP_ENV=production
APP_DEBUG=false
APP_DEBUG_LEVEL=200
LOG_CHANNEL=streamServer production with file logs:
dotenv
APP_ENV=production
APP_DEBUG=false
APP_DEBUG_LEVEL=200
LOG_CHANNEL=fileProduction Recommendations
- Set
APP_DEBUG=falseso error responses do not expose development details. - Set
APP_DEBUG_LEVEL=200for a balanced production baseline. - Use
APP_DEBUG_LEVEL=300or higher when log volume is too high. - Use
LOG_CHANNEL=streamin containers and managed platforms that collect stdout. - Use
LOG_CHANNEL=fileonly when the host has log rotation and storage permissions configured.