Where are Magento's log files located?

Where are Magento's log files located?

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Where are Magento's log files located?

Finding the default log directory in a Magento installation often feels like searching for a needle in a haystack, especially if you have never configured the application to write logs to disk by default. The confusion usually stems from the fact that Magento does not create a dedicated var/log folder automatically upon installation, nor does it populate it with entries immediately. Instead, log writing is an explicit configuration step that must be enabled in the command-line interface before any meaningful data appears.

The primary location for Magento logs is the var/log directory within your project root. However, accessing this location requires enabling logging first. If you attempt to inspect files in a fresh installation, you will likely find only empty.log, which serves as a placeholder to indicate that the logger system is active but has not yet recorded any events. To populate this directory, you must run the setup:config:set command. This command allows you to define specific log levels and destinations for various modules within the application.

When configuring logging via the CLI, you typically target the var/log directory. The command structure generally looks like this:

bin/magento setup:config:set --log-writer-path=var/log --log-writers="empty"

While the example above points to the standard location, modern Magento versions allow for more granular control over specific modules. For instance, you can configure the Magento/Framework/Logger to write to a specific file within that directory. It is crucial to understand that without running this setup command, the application might default to writing to syslog or simply discarding messages, depending on your server environment and the version of Magento you are running.

Once logging is enabled, the structure within var/log becomes more apparent. You will see files like exception.log, which captures PHP errors and stack traces, and potentially module-specific logs if those modules have been explicitly configured to write their own streams. A common pitfall for new developers is expecting a single monolithic log file named simply magento.log. Magento separates concerns by default; system exceptions go one way, while general messages might go another, or they might be aggregated depending on your specific configuration settings in the etc/di.xml or via the command-line setup.

If you are troubleshooting a production environment, relying solely on the standard var/log directory might not provide enough visibility into third-party extensions. Many modules implement their own logging mechanisms that write to custom paths defined in their own configuration XML files. These files often reside in subdirectories like app/code/Vendor/Module/etc/config.xml, where you can define a <log_file> directive pointing to a unique path outside the standard Magento hierarchy. This modular approach ensures that if one module's logs become too large, they do not impact the performance of reading other critical system logs.

Another significant consideration is log rotation. By default, Magento does not handle file size limits automatically. If you leave exception.log running without intervention, it will eventually consume all available disk space on your server. You must configure a cron job or use a system-level tool like logrotate to manage these files. Without this external management layer, the application remains vulnerable to crashes caused by full filesystems.

For developers looking to integrate logging best practices into their own modules, the pattern is straightforward: define the logger in the module's dependency injection configuration and specify a unique file path. This keeps your debug output isolated from the core system logs, making it easier to trace issues without sifting through unrelated noise. If you are managing multiple environments, ensure that your logging paths do not conflict with sensitive data or overwrite critical system files during deployment scripts.

If you require a more robust logging infrastructure than what comes out of the box, consider leveraging external services or integrating with frameworks like Laravel, which offer sophisticated logging drivers and centralized management at https://laravelcompany.com. This approach allows you to route Magento logs into a unified stack for analysis, providing a single pane of glass across your entire tech ecosystem.

Our network