If you have ever used Magento, you must have been in a situation where something in your store is not working, and you are not sure what could be the problem. Magento error logs are extremely helpful in these situations. They help you quickly find details about any issue and also help with basic troubleshooting.
That’s why it’s important to be familiar with Magento error logs. This article will provide you with a complete guide to Magento error logs so you can stay on top of any issues that arise in your store.
You’ll learn about what Magento error logs are, how to access them, and how to interpret them.
With this guide, you will be able to understand your Magento error logs and take the necessary steps to keep your store running smoothly. So let’s get started!
What Are Magento Error Logs?
Before we fully understand what Magento error logs are, let’s first understand the process that generates them in the first place.
Whenever a user creates requests on your Magento store, it is first handled by the server (Apache/ Ngnix), which is then passed on to Magento. Magento then sends the query to the MySQL database.
Errors can come up at any step of this process. This is why Magento loggers keep a record of all these activities. The logs with errors are called error logs. Essentially, Magento error logs are log files that are generated by the Magento platform to record errors, warnings, and other information that can be used to troubleshoot issues with the website.
These logs can include information such as PHP errors, database errors, system errors, and exceptions that occur within the Magento system. The logs can be used to identify any issues that may be causing the website to malfunction.
But how do you enable Magento error logs? In Magento 2, error logs are enabled by default, and you don’t have to tweak anything to enable them.
Types of Error Logs
Error logs are records that store details about issues occurring in a system, software, or application. They help identify problems and find solutions quickly.
Below are some common types of error logs:
Application Error Logs
These logs record errors within software applications. They help developers understand why an app crashes or fails to work properly. For example, if a website page does not load, the error log will show the reason behind it.
System Error Logs
System error logs store information about issues in an operating system. These errors may include hardware failures, driver issues, or system crashes. Monitoring system logs can help prevent major failures.
Security Error Logs
Security logs track unauthorized access, failed login attempts, or suspicious activities. These logs help detect cyber threats and ensure system safety. For example, if someone tries to log in multiple times with the wrong password, it gets recorded in the security log.
Server Error Logs
These logs contain errors related to web servers, such as downtime, broken links, or database connection failures. Website administrators use these logs to fix server-related issues and improve website performance.
Network Error Logs
Network logs track issues related to internet connections, slow data transfer, or failed communication between devices. These logs help troubleshoot network failures and maintain smooth connectivity.
Database Error Logs
These logs record errors in databases, such as failed queries or missing data. They help database administrators fix issues to ensure smooth data retrieval and storage.
Error logs are essential for identifying and fixing problems in different areas of a system. Regularly checking these logs can improve performance and prevent serious issues.
Where to Find Magento Error Logs?
The Magento logs can be found in the var/log/ folder and can be accessed via CLI or through FTP.
To access the error logs via the Command Line Interface, use the following command to access the logger folder:
cd public_html/var/log
Once in the folder, use the following line to view the log file:
ls -l
Understanding The Error Log Structure
Once you open the log file, you might get confused if you are looking at it for the first time. The log file has several lines, but all of them essentially have the same structure. Let’s understand its structure. The error log has 5 parts:
- Date time stamp
- Error Level (e.g., Warning, Critical, Error, etc.)
- Error Description
- Affected file
- Line number (in the affected file) where the error is generated
Let’s look at an example to better understand this:
[2023-01-11T09:58:06.506071+00:00] report.ERROR: Cron Job bshop_sync_order has an error: Warning: odbc_connect(): SQL error: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user ‘magento_staging’., SQL state 28000 in SQLConnect in /var/www/vhosts/magentotesting.bshop.com.hk/app/code/Cgo/Integration/Cron/SyncOrder.php on line 1159.
Here
- Date time stamp- [2023-01-11T09:58:06.506071+00:00]
- Error Level- report.ERROR
- Error Description- Cron Job bshop_sync_order has an error: Warning: odbc_connect(): SQL error: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user ‘magento_staging’., SQL state 28000 in SQLConnect in
- Affected file- /var/www/vhosts/magentotesting.bshop.com.hk/app/code/Cgo/Integration/Cron/SyncOrder.php
- Line number (in the affected file) where the error is generated- line 1159.
Get Notifications When Magento Errors Occur
Now that you know what Magento error logs are and how to access them, it’s time to set up a system to get notified whenever an error is logged.
Unfortunately, Magento doesn’t notify you automatically when error logs are generated, and you need to manually retrieve them.
However, if you want to get notified when error logs are generated, you can set up a cron job that’ll send you a message every time an error log is generated.
FAQs
- What are Magento error logs?
Magento error logs are files that record errors, warnings, and system issues to help troubleshoot problems. - Where can I find Magento error logs?
You can find them in thevar/log/
folder via CLI or FTP. Usecd public_html/var/log
to access them. - How do I read Magento error logs?
Each log entry includes a timestamp, error level, description, affected file, and line number. - Does Magento notify you of errors automatically?
No, Magento doesn’t send notifications, but you can set up a cron job to receive alerts. - Why are Magento error logs important?
They help identify and fix website issues quickly, improving store performance and stability.
Conclusion
In conclusion, Magento error logs are an invaluable tool for any Magento store owner. They provide detailed information about any errors that may have occurred in the store and allow you to quickly troubleshoot and fix such issues. By understanding Magento error logs, you can greatly reduce the time it takes to resolve problems and improve the overall performance of your store.
If you liked reading this article, take a look at our other best articles.
- Magento 2 Customer Attributes Guide.
- 10 Best Magento B2B Extensions for Your Business.
- 5 Common Magento 2 SEO Issues to Avoid.
Are you looking to build a Magento store from scratch? Get in touch with our expert developer’s team to help you build a customized eCommerce website tailored to your needs.