Laravel logging: channels, levels and examples
Published December 1, 2026 · Updated December 3, 2026
Laravel logging is built on Monolog and organised in channels: each channel in config/logging.php decides where a message goes (a file, stderr, syslog, Slack) and from which level. You write with the Log facade, Log::error('Payment failed', ['order' => $id]), and the default stack channel sends it to every channel it lists.
Channels in config/logging.php
The default channel is read from LOG_CHANNEL and is stack out of the box. A stack is a channel that forwards each message to several others; in a fresh application, LOG_STACK lists them and defaults to single.
The main channels the default configuration file declares (it also declares emergency, the file Laravel falls back to when a channel itself fails):
| Channel | Driver | What it does |
|---|---|---|
stack | stack | Forwards to the channels listed in LOG_STACK |
single | single | One file, storage/logs/laravel.log, growing forever |
daily | daily | One file per day, older files deleted after max_files |
monthly | monthly | One file per month, three kept by default |
slack | slack | Posts to a Slack incoming webhook, critical and above by default |
stderr | monolog | Writes to the standard error stream, for containers |
syslog | syslog | The system log |
errorlog | errorlog | PHP's error_log(), so the web server or FPM log |
papertrail | monolog | Syslog over UDP to Papertrail |
null | monolog | Discards everything |
A typical production .env writes daily files and sends the serious entries to Slack:
LOG_CHANNEL=stack
LOG_STACK=daily,slack
LOG_LEVEL=debug
LOG_DAILY_DAYS=14
LOG_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/...Note that the stock slack channel reads its level from LOG_LEVEL too (with critical only as the fallback), so with LOG_LEVEL=debug everything goes to Slack. Give that channel its own level in config/logging.php if you use it. The full list of drivers and options is in the official logging documentation.
The eight log levels
Laravel uses the eight levels of RFC 5424, from most to least severe:
| Level | Use it for |
|---|---|
emergency | The system is unusable |
alert | Someone must act immediately (database unreachable) |
critical | A component is down (payment provider failing) |
error | A runtime error that does not need instant action; Laravel logs exceptions here |
warning | Something unusual that is not an error yet (a deprecated API, a retry) |
notice | Normal but significant (an account deleted) |
info | Interesting events (a user signed in, a job finished) |
debug | Detailed information for development |
Each channel's level option is a minimum: a channel at warning records warning and everything more severe, and ignores notice, info and debug. That is how a stack can keep everything in a file while only waking people up for critical.
Writing log messages: examples
use Illuminate\Support\Facades\Log;
Log::info('Order {order} paid', ['order' => $order->id, 'amount' => $order->total]);
Log::warning('Stripe webhook retried', ['event' => $event->id, 'attempt' => $attempt]);
Log::error('Invoice generation failed', [
'invoice' => $invoice->id,
'exception' => $e,
]);Always pass data as the context array rather than concatenating it into the message. The message stays constant, so identical events read and group as one, and the values stay searchable. The {order} placeholder is replaced from the context because the default channels set replace_placeholders to true.
When you catch an exception you want to record but not rethrow, report($e) is usually better than Log::error(): it goes through the exception handler, so it is logged at the right level and also reaches any error tracker you have configured.
Context for every entry
To attach the same data to every subsequent entry, use Log::withContext(), typically in a middleware:
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use Symfony\Component\HttpFoundation\Response;
public function handle(Request $request, Closure $next): Response
{
Log::withContext(['request_id' => (string) Str::uuid()]);
return $next($request);
}withContext() applies to the current channel. Log::shareContext() does the same for every channel, including those created afterwards.
Since Laravel 11 there is also the Context facade. Data added with Context::add('trace_id', ...) is appended as metadata to every log entry of the request, and it travels with jobs dispatched to the queue, so a job's log lines carry the trace ID of the request that dispatched it. Context::addHidden() keeps a value available to your code without writing it to the logs. Details are in the Context documentation.
Writing to a specific channel
Log::channel('slack')->critical('Payment provider unreachable');
Log::stack(['daily', 'slack'])->alert('Disk almost full');
Log::build([
'driver' => 'single',
'path' => storage_path('logs/imports.log'),
])->info('Import finished', ['rows' => $count]);Log::build() creates an on-demand channel that does not exist in config/logging.php, handy for a one-off import or a script that should write to its own file.
Rotation and retention
The single channel never rotates: on a busy application laravel.log grows until the disk is full. In production, prefer daily. The default configuration keeps max_files files, read from LOG_DAILY_DAYS and 14 by default (older configuration files name the same option days, and Laravel reads both); older files are deleted when a new one is created.
Retention is also a legal question. Logs often contain personal data (IP addresses, user IDs, emails), and the GDPR requires a limited, stated retention period. Keep files as long as you need them to debug, and no longer.
If you prefer the system's logrotate, keep the single channel and let logrotate handle the file, with copytruncate so PHP keeps writing to the same file handle.
What not to log
Treat every log line as something a colleague, a backup and possibly an attacker will read.
- Never passwords, API keys, tokens, session IDs, full card numbers, or the full request body of a login or payment form.
- Avoid personal data you do not need: log a user ID rather than an email address, a country rather than a postal address.
- Watch the context array:
Log::info('Signup', $request->all())logs the password field with everything else. - Exception messages can carry values too, for example a database error that quotes the row it failed to insert.
PHP's #[\SensitiveParameter] attribute replaces a parameter's value in stack traces, which helps for functions that receive secrets. It does not filter what you pass to Log:: yourself.
JSON logs in production
Plain text lines are easy to read and hard to search. When logs are shipped to another system, write JSON. The stderr channel accepts a formatter from the environment:
LOG_CHANNEL=stderr
LOG_STDERR_FORMATTER=Monolog\Formatter\JsonFormatterFor file channels, use a tap class that swaps the formatter, as the Monolog customization section of the documentation shows:
namespace App\Logging;
use Illuminate\Log\Logger;
use Monolog\Formatter\JsonFormatter;
class UseJsonFormatter
{
public function __invoke(Logger $logger): void
{
foreach ($logger->getHandlers() as $handler) {
$handler->setFormatter(new JsonFormatter());
}
}
}'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'max_files' => env('LOG_DAILY_DAYS', 14),
'tap' => [App\Logging\UseJsonFormatter::class],
],Reading logs
On the server, the classics still work:
tail -f storage/logs/laravel.log
grep -n "production.ERROR" storage/logs/laravel-$(date +%F).logLaravel Pail tails logs from the command line with filters, and works with any log driver. It needs the PCNTL extension:
composer require --dev laravel/pail
php artisan pail --level=error
php artisan pail --filter="QueryException" -vvAs for a "Laravel log viewer" in the browser: several community packages render the log files in a web page. If you install one, protect its route with authentication and authorization, since it exposes everything your logs contain.
When files on one server stop working
Log files are fine for one developer on one server. They stop scaling quietly:
- Several servers behind a load balancer each have their own
storage/logs. The error you look for is on the other machine. - Nobody reads them. A file does not tell you anything happened. Errors pile up until a customer reports one.
- No alert, no grouping. Ten thousand identical lines look the same as ten thousand different problems.
- Containers and ephemeral servers lose their files on every redeploy.
The usual answer is to centralise: send logs to stderr and let the platform collect them, ship them over syslog, or send them to a service that stores, searches and alerts. Keep a local file as a fallback in the stack, so a network problem never costs you the evidence. Exceptions deserve their own treatment on top of that; the Laravel 500 error guide explains where they go, and the Pulse or Telescope guide compares Laravel's own observation tools.
With Quiet Guard
Quiet Guard's application logs put your log lines next to the exceptions they explain, per project. Forwarding is opt-in: the SDK listens to Laravel's MessageLogged event, so your config/logging.php does not change. Entries at or above MONITOR_LOG_LEVEL (warning by default) are buffered and sent in one batch at the end of the request, and after each queued job. Entries that carry an exception are left to exception tracking, so nothing is counted twice. Context goes through the same scrubber as exceptions, and values shaped like emails, card numbers or API tokens are masked before they leave your server. Logs are included in the Solo, Indie and Studio plans, with their own monthly quota.
composer require quiet-guard/laravel-monitorMONITOR_ENABLED=true
MONITOR_KEY=your-project-api-key
MONITOR_LOGS_ENABLED=true
MONITOR_LOG_LEVEL=warningDetails in the logging documentation.
If you are also weighing Better Stack, our comparison page lists the differences with their sources.
In Quiet Guard
Application logs
Your Laravel logs shipped as they happen, searchable by level and environment, and attached to the exception they surround.
Exception tracking
Every exception your Laravel applications throw, grouped by cause rather than by occurrence, with the full stack trace and the commit that introduced it.
Team-key encryption
The message, trace and context of your exceptions, and the message and context of your logs, sealed on arrival with your team's public key and read with your passphrase.