Docs LATEST

Logging Configuration

Log levels, daily rotation, and cleanup.

Configuration

config/logging.php controls the file logger behavior.


Keys #

Key Env Variable Default Description
path - storage/logs/velvet.log Log file path
level LOG_LEVEL info Minimum log level
daily LOG_DAILY false Enable daily rotation
max_files - 14 Days to keep when daily rotation enabled

Log levels #

PSR-3 log levels in order of severity:

Level Use case
debug Detailed debugging information
info Interesting events (user login, page created)
notice Normal but significant events
warning Exceptional occurrences that aren't errors
error Runtime errors that don't require immediate action
critical Critical conditions (component unavailable)
alert Action must be taken immediately
emergency System is unusable

Messages below the configured level are ignored.


Daily rotation #

When daily is true, logs are written to date-stamped files:

storage/logs/velvet-2026-01-28.log
storage/logs/velvet-2026-01-27.log
storage/logs/velvet-2026-01-26.log

Old files are automatically deleted when the count exceeds max_files.


Example configuration #

// user/config/logging.php
return [
    'level' => 'warning',   // Production: less noise
    'daily' => true,        // Rotate daily
    'max_files' => 30,      // Keep 30 days
];

Using the logger #

$logger = app('logger');

$logger->info('User logged in', ['user_id' => $user->id]);
$logger->error('Payment failed', ['order_id' => $order->id, 'exception' => $e]);

Or via the helper:

logger()->warning('Cache miss for key', ['key' => $cacheKey]);