Magento Error Log: Ultimate Guide

Although Magento is quite a smooth platform to work with, some common errors may still appear on the way. Thus, as a Magento developer, you need to know what is happening behind the scenes to fix the inconsistencies promptly.

In any case, when something is wrong, the first thing to check is the Magento 2 error log. The logs seem quite confusing, for both — those who only started working with Magento and even experienced developers.

So today we'll try to make things clearer for you to understand what are Magento error logs and how to work with them. 

What is Error Log in Magento 2?

Magento error log is a place where error messages, notices, and warnings are stored. The error is displayed right away, on the page, if you work in developer mode. However, that's not the case with the production mode.

Sometimes, various inconsistencies happen without you noticing. Or you may receive a message, like "An error has happened during application run...", without clear details as to what happened exactly. This is your cue to go and check the error logs.

There you'll find a full error message and, correspondingly, know where to start the fixing.

Magento Error Log Files

In Magento 2, the error log is enabled by default. Thus, you don't have to enable any extra features like in Magento 1. There are 3 main files you can find in the error log, namely system.log, exception.log, and debug.log.

Let's see what each of them is responsible for.

— displays the unexpected errors that happened during the Magento code execution. These exceptions interrupt the usual flow of various Magento 2 processes and need to be handled correspondingly.
— covers a wider range of cases. Here you'll find general error messages, warnings, and notices that have to do with the system of Magento 2 in general.
— saves the debugging data when Magento is in developer mode. In other words, you can check the firing of events, SQL queries, or other important details in the debug.log file.

Structure of Magento 2 Error Log

Each of the mentioned Magento 2 error log files captures a different type of information. Yet, we can trace a similar structure in those error messages. So, let's see what details you can find in the error log files:

Error log elements

  1. Date and time when a corresponding error was reported.
  2. The level of the error, namely EMERGENCY, WARNING, INFO, ERROR, etc.
  3. The error description is used to find out what an error is related to.
  4. The file where the error occurred.
  5. The line where the inconsistencies take place.
  6. The file and line where an error was noticed. That is, it can be happening in one place but spotted in another.

These elements may differ depending on the file you're working with. For instance, you might not find a file or a precise line in the system.log, but spot them in the exception.log.

How to Find Error Log File in Magento 2?

It's clear now what no developer can do without error logs in Magento when fixing issues. But the question is: where can you find the Magento error log?


By default, Magento 2 error logs are located in the var/log directory. You can easily access it via FTP, then download and check a corresponding error log file. Besides, you can review them right in the directory with the FTP user.

Magento 2 var/log directory

Command Line

Alternatively, you can get to the var/log directory via the command line. Just run the following command:

cd var/log

Acces Magento error log via CLI

Then you can use the below command to view a corresponding error log file.

ls -l 

View error log file using CLI


You can also view logs via the console. Just use the following command:

cat {error-log-file-name}

It may happen though, that the error log file is too large. Thus, to open and read only the specified number of lines from the file, run the below command:

tail -n {number-of-lines} {error-log-file-name}

View specifc error log lines

These are the key details you should know for starters. Remember that error logs in Magento 2 help not only to fix certain issues but to avoid them too. 

Once you master the basic concepts of Magento error logs, your troubleshooting process will be much more effective.