Simply PHP ships with structured logging powered by Monolog. The Log facade provides a clean, static API for writing log messages at any PSR-3 log level.
Create app/Config/logging.php to configure the log channel:
<?php
return [
'default' => env('LOG_CHANNEL', 'daily'),
'channels' => [
'daily' => [
'driver' => 'daily',
'path' => env('LOG_PATH', '../simply/logs/simply.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
],
],
];
Supported channels: daily (default, rotates daily, keeps 14 days), single, stderr, syslog, errorlog.
The Log facade supports all PSR-3 log levels as static methods:
use Simple\Log;
Log::debug('Query executed', ['sql' => $sql, 'time' => $ms]);
Log::info('User logged in', ['user_id' => $id]);
Log::notice('Rate limit approached', ['ip' => $ip]);
Log::warning('Disk space low', ['free' => $free]);
Log::error('Failed to send email', ['exception' => $e]);
Log::critical('Database connection lost');
Log::alert('Server is on fire');
Log::emergency('System is down');
Each method accepts a message string and an optional context array for structured data.
Attach context that appears on every log entry:
Log::withContext([
'request_id' => uniqid(),
'environment' => env('APP_ENV', 'production'),
]);
Log::info('Processing payment'); // includes request_id and environment
The level config option controls which messages are recorded. From lowest to highest severity:
debug — verbose diagnostic informationinfo — general application eventsnotice — normal but significant conditionswarning — potential issues that are not errorserror — runtime errors that should be investigatedcritical — critical conditionsalert — immediate action requiredemergency — system is unusableSetting LOG_LEVEL=error in .env will record error and above, but suppress debug, info, notice, and warning.
When SHOW_ERRORS=false in production, the framework's error handler automatically logs all exceptions and errors via Monolog with full stack traces:
// Automatically logged by Error::exceptionHandler():
// [2026-06-24 01:54:04 PM] ERROR: Undefined constant "VERSIONs"
// #0 /var/www/html/app/Controllers/HomeController.php(20): ...
// #1 /var/www/framework/src/Simple/Routing/BaseRouter.php(241): ...
You can switch the error presentation between Whoops (pretty pages) and Simply (logged-only in production) via the ERROR_HANDLER env var — see the FAQ.