How to turn on error log / error reporting in PrestaShop ?

In this article you will read something about debuging modules and other shop problems. This article should be taken as an introduction to self-troubleshooting in the own store. This tutorial works in all versions of prestashop, in 1.5 too.

 

If you have got newest prestashop (1.5.3 or higher) you need to read new tutorial - just click here

 

What exactly is error log or error reporting?

If you are running into a white shop page or some other PHP error, if something doesn't work properly in your shop based on PrestaShop engine, if something is wrong with any presta module or addon - but you have no clue what is wrong, you should consider turning on PHP error reporting. This will give you some indication of where or what the problem is. This is a good first step to solving your problem. In simple words is a web server mode which provides you and other users to read about errors, warnings, notices in your website code. By default, in PrestaShop this feature is disabled for safety reasons. Here is how to turn on PHP errors in shops based on PrestaShop:

 

Open and edit config.inc.php file

Yyou first need to find the config.inc.php file in directory config in your main prestashop dir, exactly as we show on image below:

Prestashop configuration config.inc.php file

 

you must open this file and edit one setting parameter:

1
<span style="color: #339933;" data-mce-style="color: #339933;">@</span><a href="http://www.php.net/ini_set" data-mce-href="http://www.php.net/ini_set"><span style="color: #990000;" data-mce-style="color: #990000;">ini_set</span></a><span style="color: #009900;" data-mce-style="color: #009900;">(</span><span style="color: #0000ff;" data-mce-style="color: #0000ff;">'display_errors'</span><span style="color: #339933;" data-mce-style="color: #339933;">,</span> <span style="color: #0000ff;" data-mce-style="color: #0000ff;">'off'</span><span style="color: #009900;" data-mce-style="color: #009900;">)</span><span style="color: #339933;" data-mce-style="color: #339933;">;</span>

as you probably see and as we say, the display_errors value is set to off by default. You must turn it on. How to do that?

just change 'off' param to 'on' exactly as below:

1
<span style="color: #339933;" data-mce-style="color: #339933;">@</span><a href="http://www.php.net/ini_set" data-mce-href="http://www.php.net/ini_set"><span style="color: #990000;" data-mce-style="color: #990000;">ini_set</span></a><span style="color: #009900;" data-mce-style="color: #009900;">(</span><span style="color: #0000ff;" data-mce-style="color: #0000ff;">'display_errors'</span><span style="color: #339933;" data-mce-style="color: #339933;">,</span> <span style="color: #0000ff;" data-mce-style="color: #0000ff;">'on'</span><span style="color: #009900;" data-mce-style="color: #009900;">)</span><span style="color: #339933;" data-mce-style="color: #339933;">;</span>

 

If you want advanced errors information (notices too) you should add new line:

1
<a href="http://www.php.net/error_reporting" data-mce-href="http://www.php.net/error_reporting"><span style="color: #990000;" data-mce-style="color: #990000;">error_reporting</span></a><span style="color: #009900;" data-mce-style="color: #009900;">(</span><span style="color: #0000ff;" data-mce-style="color: #0000ff;">"E_ALL"</span><span style="color: #009900;" data-mce-style="color: #009900;">)</span><span style="color: #339933;" data-mce-style="color: #339933;">;</span>

 

error_reporting parameter can have several settings, like:

 

Parameter valueDescription
E_ERROR Fatal run-time errors. Errors that can not be recovered from. Execution of the script is halted
E_WARNING Non-fatal run-time errors. Execution of the script is not halted
E_PARSE Compile-time parse errors. Parse errors should only be generated by the parser
E_NOTICE Run-time notices. The script found something that might be an error, but could also happen when running a script normally
E_CORE_ERROR Fatal errors at PHP startup. This is like an E_ERROR in the PHP core
E_CORE_WARNING Non-fatal errors at PHP startup. This is like an E_WARNING in the PHP core
E_COMPILE_ERROR Fatal compile-time errors. This is like an E_ERROR generated by the Zend Scripting Engine
E_COMPILE_WARNING Non-fatal compile-time errors. This is like an E_WARNING generated by the Zend Scripting Engine
E_USER_ERROR Fatal user-generated error. This is like an E_ERROR set by the programmer using the PHP function trigger_error()
E_USER_WARNING Non-fatal user-generated warning. This is like an E_WARNING set by the programmer using the PHP function trigger_error()
E_USER_NOTICE User-generated notice. This is like an E_NOTICE set by the programmer using the PHP function trigger_error()
E_STRICT Run-time notices. PHP suggest changes to your code to help interoperability and compatibility of the code
E_RECOVERABLE_ERROR Catchable fatal error. This is like an E_ERROR but can be caught by a user defined handle (see also set_error_handler())
E_ALL All errors and warnings, except level E_STRICT (E_STRICT will be part of E_ALL as of PHP 6.0)

 

 

Which parameter value we must use?

in our opinion the best for use is E_ALL

so set the parameter value to:

1
<a href="http://www.php.net/error_reporting" data-mce-href="http://www.php.net/error_reporting"><span style="color: #990000;" data-mce-style="color: #990000;">error_reporting</span></a><span style="color: #009900;" data-mce-style="color: #009900;">(</span><span style="color: #0000ff;" data-mce-style="color: #0000ff;">"E_ALL"</span><span style="color: #009900;" data-mce-style="color: #009900;">)</span><span style="color: #339933;" data-mce-style="color: #339933;">;</span>

and save the config.inc.php file.

 

now you can refresh your shop, and you will see errors, warnings and notices from PHP script interpreter. Now you can localize issues in your code, module codes or something else with errors :)

author milos myszczuk
Article by Milosz Myszczuk PrestaShop expert, official PrestaShop community moderator. PHP developer, specialist in relative and spatial databases management, GIS Analyst, CEO & founder of VEKIA interactive agency. Read more about VEKIA company
If you like my articles and want much more valuable tips, feel free to send me donation
1.4 version 1.4.11 1.6 404 addon admin advertise ahref ajax alpha animation api app application authentication back office backup badge banner basics block bootstrap button cache carrier cart catalog category certificate changelog chat class clear client clip cms code colors columns comments configuration contact container content controller cookie counter country coupon css csv currency customer dashboard database debug default delete delivery desktop developer device disable discount displayNav displayTop download dynamic editor effect empty encrypt engine error exchange exclude export facebook faceshop fade fancoupon fancybox fanpage fatal feature feed field file fix fixed font footer free friendly url front ftp full gallery generate gift global godaddy google google+ gray grid groupon header help hide highlight homefeatured homepage hook hosting hover howto htaccess html html5 ID image import include input instagram installation integration iPhone issue javascript jquery kgb knowhow languages law left likebox link list livingsocial loading log login logo loyality mail mailing maintenance manufacturer marketing marquee mcrypt menu meta mobile modification module movie moving multilanguage multiupload must have mysql news newsletter notification number open graph order override page password performance PHP phpmyadmin picture pinterest plugin popup post prestashop prestashop 1.0 prestashop 1.1 prestashop 1.2 prestashop 1.3 prestashop 1.4 prestashop 1.5 price rules problem product profile promotion proslider purifier quantity query quick tip random rates register reinsurance release reporting reset responsive restore results ribbon rich text right sales search security seo service shadow share shipping shop shopmania slider smarty social networks SQL SSL statistics stock store style subcategory superuser support switcher tab tablet tag tax template text theme tinyMCE tips and tricks tpl tracking translations tree trends trigger tumblr tutorial twitter update upgrade upload variables video visits voucher vulnerability web2print wide widget width window wishlist wysiwyg youtube zip zopim