How to disable Laravel 5 log file?

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company
# How to Disable or Manage Laravel Log Files for Shared Hosting Dealing with limited disk space on shared hosting environments is a common pain point for developers, especially when working with frameworks like Laravel that generate extensive debugging logs. If your application is consuming excessive space on a 1GB limit, managing those log files becomes a critical task. As a senior developer, I can tell you that simply "disabling" the logging mechanism entirely is often an anti-pattern in production. Instead, the goal should be to implement smart log rotation and management strategies. This post will guide you through effective methods to manage, reduce, or control the size of your Laravel 5 log files without sacrificing necessary debugging information. ## Understanding Where Laravel Logs Live By default, Laravel stores all application logs within the `storage/logs` directory. The primary file you are likely concerned with is `laravel.log`. These files grow continuously as the application runs, recording errors, warnings, and general activity. When you see a sudden increase in disk usage, it is usually due to these files accumulating over time without proper management. For example, if your shared host environment has strict limits, these growing logs can quickly exhaust available space, forcing the server to halt operations. Understanding this file structure is the first step toward control. ## Strategy 1: Implementing Log Rotation (The Best Practice) Since completely disabling logging hinders troubleshooting, the most robust solution is implementing automatic log rotation. This involves setting up a system that automatically archives old logs and keeps only the most recent, relevant ones. While Laravel itself doesn't include a built-in cron job for this specific task out of the box, you can leverage standard Linux tools to achieve this effectively on your hosting environment. ### Using Cron Jobs for Cleanup You can schedule a script using `cron` to run periodically and delete or compress old log files older than a specified number of days. This is highly effective for resource management in shared environments. Here is a conceptual example of how you might set up a cleanup command (this typically needs to be executed via SSH access provided by your host): ```bash # Example cron job entry to clean logs every night 0 2 * * * find /path/to/your/laravel/storage/logs -name "*.log" -mtime +30 -exec rm {} \; ``` This command tells the system to find any `.log` files in your storage directory that haven't been modified in the last 30 days (`-mtime +30`) and delete them. This keeps the log volume manageable while retaining recent data for immediate debugging. Remember, effective architecture, much like good design principles discussed by strong teams at [laravelcompany.com](https://laravelcompany.com), always prioritizes stability and resource control. ## Strategy 2: Adjusting Logging Levels (Fine-Tuning Verbosity) If the issue is excessive noise rather than sheer volume, you can control *what* gets logged by adjusting the logging levels within your application configuration. By changing the verbosity level, you tell the logger to record less detail unless a severe error occurs. You can manage this in your `config/logging.php` file. For production environments, setting the default channel to a lower severity level (like `error` or `warning`) will significantly reduce the amount of data written to disk. ```php // Example snippet from config/logging.php 'channels' => [ 'stack' => [ 'driver' => 'stack', 'channels' => ['single'], ], ], 'default' => env('LOG_CHANNEL', 'stack'), // Ensure this points to a controlled channel ``` By carefully managing the log level, you ensure that only critical operational data is written, which directly mitigates excessive disk consumption. ## Conclusion Disabling Laravel logs entirely is generally not advised for production systems where debugging capability is essential. The correct approach for shared hosting with limited space is proactive management: implement automated log rotation using system tools like `cron` and fine-tune application verbosity by adjusting logging levels in your configuration. By combining these strategies, you can maintain a healthy application while ensuring that your server resources remain within safe operational limits.