{"id":34709,"date":"2024-12-09T14:30:52","date_gmt":"2024-12-09T09:30:52","guid":{"rendered":"https:\/\/devrims.com\/?p=34709"},"modified":"2025-03-24T15:42:18","modified_gmt":"2025-03-24T10:42:18","slug":"debug-magento-2-store","status":"publish","type":"post","link":"https:\/\/devrims.com\/blog\/debug-magento-2-store\/","title":{"rendered":"How To Debug Magento 2 Store &#8211; Easy Steps"},"content":{"rendered":"\r\n\r\n\r\n\r\n\r\n\r\n\n<p>This blog covers the actual quick methods for Magento 2 debugging.<\/p>\n\n\n\n<p>Debugging is an essential part of every development project or eCommerce store. Every Developer knows how necessary it is to debug the Magento 2 store when needed.<\/p>\n\n\n\n<p>Magento 2 is a newer version of Magento; debugging Magento 2 is slightly different from Magento 1. For a developer, it is crucial to learn about it because Magento&#8217;s market share has increased from <a href=\"https:\/\/websitebuilder.org\/blog\/magento-statistics\/\" target=\"_blank\" rel=\"nofollow noopener\">9% to 13%<\/a> in just the last year!<\/p>\n\n\n\n<p>For a breakdown of Magento 1 and Magento 2, read our blog on which <a href=\"https:\/\/devrims.com\/blog\/which-version-of-magento-should-you-use\/\" target=\"_blank\" rel=\"noopener\">Magento version you should choose<\/a>.<\/p>\n\n\n\n<p>There are multiple methods used to debug code in a Magento 2 Store. In this article, I will show you some of the best Magento debugging methods so you can conveniently use the Magento 2 eCommerce store.<\/p>\n\n\n\n<h2 id='why-do-you-need-to-debug-magento-2-store'  id=\"boomdevs_1\" class=\"wp-block-heading\">Why Do You Need to Debug Magento 2 Store?<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/devrims.com\/blog\/wp-content\/uploads\/2021\/05\/3.1.png\" alt=\"Why Do You Need to Debug Magento 2 Store?\"\/><\/figure>\n\n\n\n<p>Debugging is the testing framework; it will help you identify the bugs in your Magento eCommerce store. It will also assist you in resolving bugs\/errors or abnormalities in computer programs.<\/p>\n\n\n\n<h2 id='type-of-development-mode-in-magento-2-debugging'  id=\"boomdevs_2\" class=\"wp-block-heading\">Type of Development Mode in Magento 2 Debugging<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/devrims.com\/blog\/wp-content\/uploads\/2021\/05\/3.2.png\" alt=\"Type of Development Mode in Magento 2\"\/><\/figure>\n\n\n\n<p>Before going through the methods of debugging Magento 2, you need to understand the types of development modes. There are three types of development modes: Default, Developer, and Production mode\u2014Let&#8217;s discuss each of them one by one:<\/p>\n\n\n\n<h3 id='1-default-mode'  id=\"boomdevs_3\" class=\"wp-block-heading\">1- Default mode<\/h3>\n\n\n\n<p>If no other mode is enabled, the default mode is \u201cthe default mode\u201d with no amendments, changes, editing, personalization, or additions. This mode allows the following things:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The error is not displayed to the visitors when using default mode and is stored in log files.<\/li>\n\n\n\n<li>The static files are published to the pub\/static record to make them faster.<\/li>\n\n\n\n<li>The static file is dynamically generated in response to a request.<\/li>\n<\/ul>\n\n\n\n<h3 id='2-developer-mode'  id=\"boomdevs_4\" class=\"wp-block-heading\">2- Developer Mode<\/h3>\n\n\n\n<p>The developer mode is used for development. It includes the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The static files are published to the pub\/static record (as in the default mode). With that, they are always generated from basic templates.<\/li>\n\n\n\n<li>Users can see the errors. It is displayed in the browser.<\/li>\n\n\n\n<li>Errors that get in <strong>var\/reports<\/strong> are more detailed.<\/li>\n<\/ul>\n\n\n\n<h3 id='3-production-mode'  id=\"boomdevs_5\" class=\"wp-block-heading\">3- Production mode<\/h3>\n\n\n\n<p>Production mode is one of the best modes. It is fully optimized and suitable for server production. The production mode offers all data that will be loaded from the cache.<\/p>\n\n\n\n<p>This mode allows the following things:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The errors will not display in the log files<\/li>\n\n\n\n<li>The static files are displayed only in the cache.<\/li>\n<\/ul>\n\n\n\n<p>To change the developer mode&#8217;s production mode, you must navigate bin\/Magento starting with settings <strong>deploy:mode: set Developer<\/strong>.<\/p>\n\n\n\n<p>After that, you need to delete the content of the directories that we mention below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/*Code Start\/*<br>var\/cache<br>var\/di<br>var\/generation<br>var\/view_preprocessed<br>pub\/static<br>\/*Code End\/*<\/pre>\n\n\n\n<p><strong>Note:<\/strong> <em>Do not delete the .htaccess file and the <strong>pub\/static\/deployed_version.txt<\/strong> file.<\/em><\/p>\n\n\n\n<h2 id='best-methods-of-debugging-magento-2-store'  id=\"boomdevs_6\" class=\"wp-block-heading\">Best Methods of Debugging Magento 2 Store<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/devrims.com\/blog\/wp-content\/uploads\/2021\/05\/3.3.png\" alt=\"Methods of Debugging Magento 2 Store\"\/><\/figure>\n\n\n\n<p>I have mentioned some of the best methods to check out and debug your Magento 2 eCommerce store. Let\u2019s see how each method can make your Magento 2 store faster and wiser.<\/p>\n\n\n\n<h3 id='xdebug-and-phpstorm-combination'  id=\"boomdevs_7\" class=\"wp-block-heading\">Xdebug and PhpStorm Combination<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/devrims.com\/blog\/wp-content\/uploads\/2021\/05\/3.4-1024x528.png\" alt=\"Xdebug and PhpStorm Combination\"\/><\/figure>\n\n\n\n<p>Xdebug and PhpStorm are both great combinations for debugging Magento 2. The main benefit of the method is the breakpoints installation process, and it can assist the Developer in reviewing and changing variables at any time<\/p>\n\n\n\n<h3 id='magento-2-developer-mode'  id=\"boomdevs_8\" class=\"wp-block-heading\">Magento 2 Developer mode<\/h3>\n\n\n\n<p>Magento developer mode shows the errors on your browser screen. If you want to enable this mode, you need to add the following code line in the directory using the console:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">php bin\/magento deploy:mode:set developer<\/pre>\n\n\n\n<h3 id='enable-template-path-hints'  id=\"boomdevs_9\" class=\"wp-block-heading\">Enable &#8216;Template Path Hints<\/h3>\n\n\n\n<p>The template path hints method shows the names of all page blocks and classes. To enable the template path, you need to do the following steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Login into your Magento 2 store<\/li>\n\n\n\n<li>Next, navigate the store configuration<\/li>\n\n\n\n<li>Next, go to the Advanced section and click on the Developer<\/li>\n\n\n\n<li>Next, extend Debug from the menu and set Enabled Template Path Hints for Storefront<\/li>\n\n\n\n<li>Next, enable Template Path Hints for Admin and Add Block Names to Hints to YES.<\/li>\n<\/ul>\n\n\n\n<h3 id='enable-magento-2-display-errors'  id=\"boomdevs_10\" class=\"wp-block-heading\">Enable Magento 2 Display Errors<\/h3>\n\n\n\n<p>Magento 2 does not show the display error on the screen. However, if you want to show this error, you must rename the <strong>local.xml.The sample<\/strong> file was placed in <strong>pub\/errors<\/strong> to <strong>local.xml<\/strong>.<\/p>\n\n\n\n<p>The content of local.xml.sample:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?xml version=\"1.0\"?&gt;<br>&lt;!--<br>\/**<br>* Copyright \u00a9 Magento, Inc. All rights reserved.<br>* See COPYING.txt for license details.<br>*\/<br>--&gt;<br>&lt;config&gt;<br>&lt;skin&gt;default&lt;\/skin&gt;<br>&lt;report&gt;<br>&lt;!--<br>\"action\" can be set to \"print\" to show exception on screen and \"email\"<br>to send exception on specified email<br>--&gt;<br>&lt;action&gt;print&lt;\/action&gt;<br>&lt;!--<br>in \"subject\" you can set subject of email<br>--&gt;<br>&lt;subject&gt;Store Debug Information&lt;\/subject&gt;<br>&lt;!--<br>\"email_address\" admin email address<br>--&gt;<br>&lt;email_address&gt;&lt;\/email_address&gt;<br>&lt;!--<br>\"trash\" is handle about trace info<br>value \"leave\" is for store on disk<br>value \"delete\" is for cleaning<br>--&gt;<br>&lt;trash&gt;leave&lt;\/trash&gt;<br>&lt;\/report&gt;<br>&lt;\/config&gt;<\/pre>\n\n\n\n<h3 id='magento-2-logs'  id=\"boomdevs_11\" class=\"wp-block-heading\">Magento 2 Logs<\/h3>\n\n\n\n<p>This method is hidden from the user and doesn&#8217;t require data display on the screen. Furthermore, in Magento 2, the PsrLogLoggerInterface class provides logging events and output variables to Magento log files.&nbsp;<\/p>\n\n\n\n<p>Following are the public methods that you can see:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">emergency($message, array $context = array())<br>alert($message, array $context = array())<br>critical($message, array $context = array())<br>error($message, array $context = array())<br>warning($message, array $context = array())<br>notice($message, array $context = array())<br>info($message, array $context = array())<br>debug($message, array $context = array())<br>log($level, $message, array $context = array())<\/pre>\n\n\n\n<h2 id='frequently-asked-questions'  id=\"boomdevs_12\" class=\"wp-block-heading\">Frequently Asked Questions<\/h2>\n\n\n\n<p>Here are answers to some frequently asked questions.<\/p>\n\n\n<div ><style>#sp-ea-65566 .spcollapsing { height: 0; overflow: hidden; transition-property: height;transition-duration: 300ms;}#sp-ea-65566.sp-easy-accordion>.sp-ea-single {margin-bottom: 10px; border: 1px solid #e2e2e2; }#sp-ea-65566.sp-easy-accordion>.sp-ea-single>.ea-header a {color: #444;}#sp-ea-65566.sp-easy-accordion>.sp-ea-single>.sp-collapse>.ea-body {background: #fff; color: #444;}#sp-ea-65566.sp-easy-accordion>.sp-ea-single {background: #eee;}#sp-ea-65566.sp-easy-accordion>.sp-ea-single>.ea-header a .ea-expand-icon { float: left; color: #444;font-size: 16px;}<\/style><div id=\"sp_easy_accordion-1720700401\"><div id=\"sp-ea-65566\" class=\"sp-ea-one sp-easy-accordion\" data-ea-active=\"ea-click\" data-ea-mode=\"vertical\" data-preloader=\"\" data-scroll-active-item=\"\" data-offset-to-scroll=\"0\"><div class=\"ea-card ea-expand sp-ea-single\"><h3 id='how-do-you-activate-error-messages-in-magento-2'  id=\"boomdevs_13\" class=\"ea-header\"><a class=\"collapsed\" id=\"ea-header-655660\" role=\"button\" data-sptoggle=\"spcollapse\" data-sptarget=\"#collapse655660\" aria-controls=\"collapse655660\" href=\"#\" aria-expanded=\"true\" tabindex=\"0\"><i aria-hidden=\"true\" role=\"presentation\" class=\"ea-expand-icon eap-icon-ea-expand-minus\"><\/i> How do you activate error messages in Magento 2?<\/a><\/h3><div class=\"sp-collapse spcollapse collapsed show\" id=\"collapse655660\" data-parent=\"#sp-ea-65566\" role=\"region\" aria-labelledby=\"ea-header-655660\"> <div class=\"ea-body\"><p>There are two methods that you can use.<\/p><ol><li>Changing mode into the \u201cdeveloper.\u201d<\/li><li>Rename local.xml.sample in pub\/error directory to local.xml<\/li><\/ol><\/div><\/div><\/div><div class=\"ea-card sp-ea-single\"><h3 id='what-is-xdebug-php'  id=\"boomdevs_14\" class=\"ea-header\"><a class=\"collapsed\" id=\"ea-header-655661\" role=\"button\" data-sptoggle=\"spcollapse\" data-sptarget=\"#collapse655661\" aria-controls=\"collapse655661\" href=\"#\" aria-expanded=\"false\" tabindex=\"0\"><i aria-hidden=\"true\" role=\"presentation\" class=\"ea-expand-icon eap-icon-ea-expand-plus\"><\/i> What is Xdebug PHP?<\/a><\/h3><div class=\"sp-collapse spcollapse \" id=\"collapse655661\" data-parent=\"#sp-ea-65566\" role=\"region\" aria-labelledby=\"ea-header-655661\"> <div class=\"ea-body\"><p>Xdebug is using the DBGp debugging protocol. It is a PHP extension that provides debugging capabilities.<\/p><\/div><\/div><\/div><div class=\"ea-card sp-ea-single\"><h3 id='what-does-debugging-mean'  id=\"boomdevs_15\" class=\"ea-header\"><a class=\"collapsed\" id=\"ea-header-655662\" role=\"button\" data-sptoggle=\"spcollapse\" data-sptarget=\"#collapse655662\" aria-controls=\"collapse655662\" href=\"#\" aria-expanded=\"false\" tabindex=\"0\"><i aria-hidden=\"true\" role=\"presentation\" class=\"ea-expand-icon eap-icon-ea-expand-plus\"><\/i> What does Debugging mean?<\/a><\/h3><div class=\"sp-collapse spcollapse \" id=\"collapse655662\" data-parent=\"#sp-ea-65566\" role=\"region\" aria-labelledby=\"ea-header-655662\"> <div class=\"ea-body\"><p>Debugging is the process of identifying your Magento 2 store\u2019s error.<\/p><\/div><\/div><\/div><div class=\"ea-card sp-ea-single\"><h3 id='what-is-magento-2-debug-log'  id=\"boomdevs_16\" class=\"ea-header\"><a class=\"collapsed\" id=\"ea-header-655663\" role=\"button\" data-sptoggle=\"spcollapse\" data-sptarget=\"#collapse655663\" aria-controls=\"collapse655663\" href=\"#\" aria-expanded=\"false\" tabindex=\"0\"><i aria-hidden=\"true\" role=\"presentation\" class=\"ea-expand-icon eap-icon-ea-expand-plus\"><\/i> What is Magento 2 Debug Log?<\/a><\/h3><div class=\"sp-collapse spcollapse \" id=\"collapse655663\" data-parent=\"#sp-ea-65566\" role=\"region\" aria-labelledby=\"ea-header-655663\"> <div class=\"ea-body\"><p>Magento 2 debug log is a tool that records detailed system events and errors to help developers identify and fix issues<\/p><\/div><\/div><\/div><div class=\"ea-card sp-ea-single\"><h3 id='how-to-enable-debug-mode-in-magento-2'  id=\"boomdevs_17\" class=\"ea-header\"><a class=\"collapsed\" id=\"ea-header-655664\" role=\"button\" data-sptoggle=\"spcollapse\" data-sptarget=\"#collapse655664\" aria-controls=\"collapse655664\" href=\"#\" aria-expanded=\"false\" tabindex=\"0\"><i aria-hidden=\"true\" role=\"presentation\" class=\"ea-expand-icon eap-icon-ea-expand-plus\"><\/i> How to enable debug mode in Magento 2?<\/a><\/h3><div class=\"sp-collapse spcollapse \" id=\"collapse655664\" data-parent=\"#sp-ea-65566\" role=\"region\" aria-labelledby=\"ea-header-655664\"> <div class=\"ea-body\"><p>By default, the debug log is on in default or develop mode and off in production mode. Here\u2019s how to enable the debug mode to the true or false value.<\/p><p>Use:<\/p><pre class=\"wp-block-preformatted\"><em>bin\/magento setup:config:set --enable-debug-logging=true<\/em><\/pre><p>or<\/p><pre class=\"wp-block-preformatted\"><em>bin\/magento setup:config:set --enable-debug-logging=false<\/em><\/pre><\/div><\/div><\/div><\/div><\/div><\/div>\n\n\n<h2 id='final-words'  id=\"boomdevs_18\" class=\"wp-block-heading\">Final Words<\/h2>\n\n\n\n<p>Debugging Magento 2 is a skill that will set you apart from most of the developers. Learning how to debug Magento 2 is crucial in the current era because customization and personalization are most important for eCommerce stores.<\/p>\n\n\n\n<p>I hope this will be sufficient to debug a Magento 2 store using the methods mentioned above.<\/p>\n\n\n\n<p>Also, if you have experienced one of the methods mentioned earlier, share it with us. We highly appreciate your feedback. For any queries, contact us at <a href=\"mailto:info@devrims.com\">info@devrims.com<\/a>.<\/p>\n\n\n\n<p>If you want a secure hosting platform with free migration, check out Devrims <a href=\"https:\/\/devrims.com\/magento-hosting\/\" target=\"_blank\" rel=\"noopener\">Magento Hosting<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This blog covers the actual quick methods for Magento 2 debugging. Debugging is an essential part of every development project or eCommerce store. Every Developer knows how necessary it is to debug the Magento 2 store when needed. Magento 2 is a newer version of Magento; debugging Magento 2 is slightly different from Magento 1. [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":65547,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[8],"tags":[47],"ad-banner":[84],"blog-popup":[80],"cta-banner":[],"class_list":["post-34709","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-magento","tag-magento-development","ad-banner-magento","blog-popup-app-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/posts\/34709","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/comments?post=34709"}],"version-history":[{"count":8,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/posts\/34709\/revisions"}],"predecessor-version":[{"id":65572,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/posts\/34709\/revisions\/65572"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/media\/65547"}],"wp:attachment":[{"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/media?parent=34709"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/categories?post=34709"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/tags?post=34709"},{"taxonomy":"ad-banner","embeddable":true,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/ad-banner?post=34709"},{"taxonomy":"blog-popup","embeddable":true,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/blog-popup?post=34709"},{"taxonomy":"cta-banner","embeddable":true,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/cta-banner?post=34709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}