Brieflyn
Navigation Menu
Home › Tutorials & How-To › How to Configure Laravel Logging in Production – 2026 Guide

How to Configure Laravel Logging in Production – 2026 Guide

How to Configure Laravel Logging in Production – 2026 Guide
By Brieflyn Editorial Team • Published: August 17, 2026 • 13 min read (2,433 words) • 38 views
Learn how to Configure Laravel Logging in Production in 2026 with best practices, SQLite WAL, Monolog stack, Docker restart policies, and real‑world trade‑offs.

How to Configure Laravel Logging in Production - 2026 technical guide cover

How to Configure Laravel Logging in Production is one of those tasks every Laravel team eventually wrestles with the hard way: a single-file log grows to 8 GB, Slack notifications stop firing, or a SQLite-backed log table starts locking under load. After shipping production stacks for high-traffic SaaS products in 2026, I can tell you the right setup is not the one with the most destinations; it is the one that survives your worst traffic spike without a 3 a.m. page. This guide walks through Monolog channels, Octane persistence, Docker realities, and the trade-offs you will actually feel under load.

Overview: How to Configure Laravel Logging in Production – Quick Answer

What the article covers

Laravel's logging layer is built on Monolog, configured through config/logging.php and the LOG_CHANNEL environment variable. In production you need rotation, multiple destinations, and a channel strategy that survives Octane's long-lived workers. This article covers channel configuration, Monolog stack channels, container concerns, performance benchmarks, and persona-matched recommendations.

Key takeaway

Use a stack channel that combines a rotating file driver with at least one remote sink (Papertrail, Slack, or a custom handler). Set LOG_LEVEL=warning in production, persist logs to a mounted volume or external service, and tune the SQLite WAL pragma if you log to a database.

Why Logging Matters in 2026: Trends & Compliance

Yellow material handler lifting logs at a lumber yard, showcasing modern industrial machinery in action.
Photo by Mark Stebnicki via Pexels. Laravel Logging In Production Technology.

Regulatory

Compliance pressure in 2026 makes logs a first-class artifact. SOC 2 Type II audits, GDPR data-access requests, and the new PCI DSS v4.0.1 logging requirements all demand tamper-evident, retained records. Plain text files in a container's writable layer will not satisfy an auditor. You need immutable or append-only destinations, retention windows you can prove, and the ability to mask sensitive fields before they ever land in a log line.

Performance Monitoring

Logs are no longer a postmortem tool; they are a real-time signal. Many teams now feed structured JSON logs directly into observability pipelines alongside metrics. Laravel's Monolog integration makes this easy: a JsonFormatter or third-party driver like Pail can emit structured events that downstream tools index and correlate with traces. Skip this and you are effectively flying blind on production behavior.

Developer Experience

A clean log stream in New Relic or Papertrail turns a 40-minute "why is this queue failing" investigation into a 90-second search. The 2026 standard for any serious Laravel shop is searchable, contextual logs with request IDs, user IDs, and trace correlation. The cost of getting this right is a few hours of config work; the cost of skipping it compounds forever.

Prerequisites & Environment Checklist

PHP & Laravel Version

Run PHP 8.4 in production. Laravel 11.x and 12.x are the actively supported lines in 2026, and both ship with the modern Monolog 3.x bindings and the streamlined channel configuration. Older Laravel versions still work, but you will be writing config by hand instead of leveraging the refined stack channel defaults documented in the Laravel logging documentation.

OS & Disk Setup

Provision a dedicated volume for logs. On a Hetzner dedicated box or similar VPS, mount /var/log/laravel on a separate partition so a runaway log file cannot fill your root filesystem. Set disk usage alerts at 70% and 85%. Use ext4 or XFS; both handle append-heavy workloads well.

Container Orchestration

Docker Compose is the default for single-host Laravel stacks. The 6 ms production-ready stack pattern separates web, worker, scheduler, redis, and database into isolated containers, with Traefik labels handling port 80/443 routing. Each container gets its own log volume or stdout stream depending on your aggregation strategy.

Monitoring Tools

Install Laravel Horizon for queue visibility, Laravel Pulse for application health, and a third-party log sink (New Relic, Papertrail, or self-hosted Loki). New Relic's PHP agent can be configured to read Laravel log lines through a custom Monolog handler, which is the cleanest path for full-stack observability.

Configuring the Default Monolog Channels

Stack of cut logs covered in snow, showcasing a cold winter texture and woody elements.
Photo by Alexis Caso via Pexels. Laravel Logging In Production Concept.

File System with Rotating Files

The daily driver is the workhorse for production. It writes to storage/logs/laravel-YYYY-MM-DD.log and keeps a configurable retention window. In config/logging.php:

'daily' => [
 'driver' => 'daily',
 'path' => storage_path('logs/laravel.log'),
 'level' => env('LOG_LEVEL', 'warning'),
 'days' => env('LOG_DAILY_DAYS', 14),
 'bubble' => true,
 'permission' => 0644,
 'locking' => true,
],

The locking option is critical under Octane where multiple worker processes might attempt concurrent writes. Set days to match your compliance window; 14 is a sensible default for most apps, while healthcare-adjacent workloads should consider 90+ days with archival to cold storage.

SQLite WAL for Production Logging

Logging to SQLite is a contrarian choice that works exceptionally well for single-server deployments. According to the Laravel News SQLite production guide, the key is enabling WAL mode and a reasonable busy timeout. In config/database.php:

'sqlite' => [
 'driver' => 'sqlite',
 'url' => env('DB_DATABASE', database_path('database.sqlite')),
 'database' => env('DB_DATABASE', database_path('database.sqlite')),
 'prefix' => '',
 'foreign_key_constraints' => true,
 'busy_timeout' => 10000,
 'journal_mode' => 'wal',
],

You can also set these via PRAGMA statements: pragma journal_mode = wal; and pragma busy_timeout = 10000;. This gives you the speed of a local file with queryable log data, ideal when you want to analyze error patterns without grepping through rolling files.

Remote Log Drivers (Papertrail, Slack, Pail)

Papertrail remains the simplest off-host log sink. Configure it as a Monolog channel with host and port pulled from environment variables. Slack is best reserved for ERROR-level and above; you do not want INFO noise pinging a channel at 3 a.m. Pail is the newer Laravel-native package for tailing logs, useful in dev rather than production shipping. Never commit webhook URLs or Papertrail credentials to the repository; reference them through .env and your secrets manager.

Monolog Stack Channels

The stack driver is what makes multi-destination logging painless. As described in the Laravel 13.x logging docs, you aggregate multiple channels into a single named channel. In production:

'production' => [
 'driver' => 'stack',
 'channels' => ['daily', 'slack', 'papertrail'],
 'ignore_exceptions' => false,
],

Set LOG_CHANNEL=production and a single Log::error() call propagates to all three destinations. The bubble option on each underlying channel controls whether processing stops at the first handler; keep bubble => true for the daily file and the remote sinks will still receive every event.

Docker & Process Management Alternatives

Docker Restart Policies vs Supervisor

Inside a container, Supervisor is overkill. Use restart: unless-stopped in docker-compose.yml and let Docker's built-in process supervisor handle restarts. The hackernoon production stack pattern keeps each long-lived process in its own container, so a Horizon crash never takes down the web tier. Supervisor in production is only necessary if you are running a bare-metal PHP-FPM setup outside of containers; the process noise it generates rarely justifies the benefit.

Laravel Octane & Swoole for Persistent Logging

Octane keeps the framework in memory, which is wonderful for performance and slightly tricky for logs. The standard Monolog handlers can lose buffered entries when Swoole or RoadRunner reloads a worker, so prefer handlers that flush synchronously or write directly to stdout. With Octane, route your stack channel through a custom Monolog handler that wraps StreamHandler pointed at php://stdout; Docker's log driver will then capture everything for the host.

Integrating with Traefik for Log Routing

Traefik itself does not handle application logs, but its access logs are useful to correlate with Laravel request logs. Configure Traefik with the accesslog enabled and add request IDs at the proxy level; pass them through to Laravel via the X-Request-Id header. Your log entries can then include the same ID, giving you a clean thread from edge to database query.

Real-World Trade-Offs & Performance Benchmarks

Disk Space vs Log Retention

A busy Laravel app produces 200–500 MB of logs per day at INFO level. Drop to warning and you cut that by 70–80%. The pragmatic policy: keep 14 days of WARNING+ on local disk, ship everything to a remote sink for long-term retention, and compress daily files older than 7 days. Logrotate outside the container handles this cleanly when logs live on a mounted volume.

Synchronous vs Asynchronous Logging Latency

Synchronous file writes under Octane add 1–3 ms per request when the daily handler is hot. Remote sinks like Papertrail can add 15–50 ms over WAN. The fix is a buffered handler or a queue-backed log writer. Pail's database driver can be wrapped in a queued job for non-critical log levels, ensuring that ERROR events still write immediately while INFO events ship asynchronously.

Handling High-Volume Traffic (Redis, Horizon, Pulse)

If you log from queue workers, you are writing in tight loops. The fix is twofold: aggregate first, write second. Use Redis as a temporary buffer with a Horizon job that flushes to your permanent sink every 30 seconds, and rely on Pulse to surface aggregate metrics rather than logging every heartbeat. The 6 ms production stack pattern is built around this exact insight.

Best Practices & Security Considerations

Masking Sensitive Data

Never log raw passwords, API tokens, or full credit card numbers. Use a custom Monolog processor that scrubs known sensitive keys from the context array before any handler sees the record. The Laravel community has published several packages for this; the core pattern is a SanitizeContextProcessor that strips values where the key matches a configurable list (password, secret, authorization, etc.).

Log Rotation & Archiving Strategies

For files: rely on the daily driver's days setting plus a host-level logrotate policy for compression. For SQLite: run a nightly vacuum job to reclaim space, and ship older entries to S3 or equivalent cold storage. For remote sinks: configure retention at the provider; Papertrail offers 1-year archives and New Relic's data options extend to 90 days on standard plans.

Monitoring Log Health with New Relic & Horizon

Set up alerts in New Relic for log volume anomalies (a sudden drop often means logging is broken, not that the app got healthier). Horizon's dashboard surfaces failed jobs that often correlate with log gaps, and Pulse's slow-query and exception panels complement the log stream rather than duplicating it.

Common Pitfalls & Troubleshooting Guide

Permission Errors & File Ownership

The single most common production issue: laravel.log is owned by the web user (www-data) and the CLI scheduler runs as a different user (forge, root). Set the directory to a shared group with chmod -R 2775 storage/logs and ensure both users are in the same group. The permission => 0644 option in your channel config is a band-aid, not a fix.

SQLite Locking & WAL Misconfigurations

If you log to SQLite and see "database is locked" errors under load, your busy_timeout is too low. Bump it to 10000 ms as the SQLite production guide recommends. Also confirm WAL is actually enabled by querying pragma journal_mode; directly; some PRAGMAs only stick on a per-connection basis, so verify the Laravel config is the source of truth.

Misconfigured Monolog Handlers

Duplicate log entries usually mean a stack channel includes a parent channel that is itself a stack. Avoid nesting stacks; instead, list each underlying channel directly. Another frequent mistake: setting LOG_LEVEL=debug in production through an inherited .env, flooding your log sink and your wallet in one stroke.

Who Should Use Which Strategy? Persona Table

Target Persona Recommended Option Key Reason & Real-World Benefit
Solo Developer / Small Team Daily file driver + Slack channel via stack Zero-cost, simple to set up, no external dependency to manage. Slack provides instant visibility without paying for a log SaaS.
Ops-Focused Deployment (Compliance) SQLite WAL + Papertrail stack with strict retention Queryable local logs for audits plus immutable remote sink. SQLite retention is provable and the file is easy to back up.
High-Traffic SaaS Daily file + Redis buffer + New Relic with queued flush Asynchronous writes protect request latency under load. New Relic provides correlation with traces and metrics for fast root cause.
Octane / Swoole Shop Stack channel with stdout StreamHandler + remote sink Stdout captures survive worker reloads; Docker log driver handles rotation. Avoids in-memory log buffer loss.

Frequently Asked Questions

By default, Laravel uses the "stack" channel defined in config/logging.php, which aggregates the "single" channel. The actual channel used can be overridden by setting the LOG_CHANNEL environment variable.

No comments yet. Be the first to share your technical feedback!

Leave Technical Feedback / Discussion

B

Brieflyn Editorial Team

Senior cybersecurity researchers, DevOps engineers, and technical editors at Brieflyn.

EXPERTISE: CYBERSECURITY, CLOUD INFRASTRUCTURE, & SOFTWARE SYSTEMS

Related Guides & Documentation