The Techjoomla Blog

Stay updated with all the latest happenings at Techjoomla. From news about the developments in your favourite extensions to Tips & Tricks about the Joomla CMS, Framework & Development.
Font size: +
1 minute reading time (143 words)

Using Joomla logging to easily debug MySQL issues

Using-Joomla-logging-to-easily-debug-MySQL-issues
Sometimes, you might have operations like crons running PHP scripts behind the scenes. If there are any errors in it, it can become difficult to debug them since they might not affect the entire website. Whether you are doing this with any PHP framework or in a Joomla component, logging can help you debug such issues.
Here is how you can use Joomla's logging functionality to log your errors to a file.
jimport('joomla.log.log'); //import this file on top of the file
 
//write db log code inside your function
JLog::addLogger(
array(
        //Sets file name
        'text_file' => 'com_test.errors.php'
        ),
 
//Sets all JLog messages to be set to the file
 JLog::ALL,
 //Chooses a component name
 'com_test'
 );
 
//insertion code :-
if(!$db->insertObject($table_name, $final_array, 'id')){
 
$logEntry = $db->stderr();   //logentry variable
 
// Log my extension errors only.
JLog::add($logEntry, JLog::WARNING, 'com_test');
 
return false;
} 

Logs shall be stored in yoursiteroot/logs/com_test.errors.php

1
×
Stay Informed

When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.

SocialAds v2.9.4 out
Programatically delete Zoo items

Related Posts

 

Blog Topics