[SOLUTION] Deep SQL commands logging

For articles specific to version 5.x
Post Reply
John Snow
Posts: 12
Joined: Tue Feb 23, 2010 8:01 pm

[SOLUTION] Deep SQL commands logging

Post by John Snow »

Hi guys,

during past two days I was fighting with import problem in ISC 5.5.2. No matter what, I could not import my products into a category consisting of central european characters, like é, á, ž, č, etc. I will write separate post including solution about this, but now I am going to show you what helped me find the solution.

After numerous and numerous attempts to locate the "root of evil" I found out ISC can keep track of its internal SQL queries and write them into text files which can (and very likely will) offer you lots of information when fighting with internal problems. I was (and still am) using FirePHP as it is really useful for this kind of stuff, but this came really in handy. So, if you would like to enable this logging, do the following:

First of all, enable debug mode in the ISC admin panel. Then, create a folder called "logs" inside your root directory.
After that, open file [root]/lib/init.php and around line 267 look for the following line:

Code: Select all

$db = new $db_type();
After this line, put this code:

Code: Select all

$GLOBALS['Debug'] = $GLOBALS['ISC_CFG']['DebugMode'];
What this code basically does is that it enables built in DB logging function. In 5.5.2, this is not working by default, as there is missing line which connects your desired loggin state in config.php file with $GLOBALS['Debug'] variable. I have "bridged" this problem by assigning it a proper value from config.php file, so it is not empty anymore :)

Now browse around the shop and look inside your newly created "logs" folder. You will see three TXT files with logged times, errors and SQL queries inside. Enjoy :)

NOTICE: DO NOT forget to disable this functionality on live servers. I guess hackers would be mighty pleased :)

Enjoy and leave a comment, folks! Do not forget - we are helping each other.
If you are interested in my posts and want a reply, please DO USE private messages. I do not narcissistically check my posts.
Post Reply