Debugging Joomla! code with JLog

130 views
Skip to first unread message

PGS

unread,
Nov 16, 2015, 2:04:43 PM11/16/15
to Joomla! General Development
At file: libraries\joomla\database\driver\mysqli.php
At: public function execute() {
After '$query = $this' etc I added:
jimport('joomla.log.log');
JLog::add('query:'.$query);

So that I would be able to see the queries being executed.

But an error was returned:
"Error displaying the error page: Application Instantiation Error: Application Instantiation Error"

Can't I echo (with JLog::Add or enqueMessage or something else?? ) from this function?
Is there some way to overcome this?

Mark Dexter

unread,
Nov 16, 2015, 4:42:00 PM11/16/15
to Joomla! General Development
I think you need to first create an instance of JLogger using JLog::addLogger. If you look at how the logging is done in core, you will see something like the following:

$options['format']    = '{DATE}\t{TIME}\t{LEVEL}\t{CODE}\t{MESSAGE}';
$options['text_file'] = 'joomla_update.php';

JLog::addLogger($options, JLog::INFO, array('Update', 'databasequery', 'jerror'));
JLog::add(JText::_('COM_JOOMLAUPDATE_UPDATE_LOG_DELETE_FILES'), JLog::INFO, 'Update');

You only need one instance of the logger and then you can use JLog:add() as many times as you need.

Hope that helps. Mark


--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To post to this group, send an email to joomla-de...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/d/optout.

er...@digital-garage.com.au

unread,
Nov 16, 2015, 11:16:30 PM11/16/15
to joomla-de...@googlegroups.com
Hey PGS, with JLog::add if you want to also echo the message to the message queue (ie. similar to enqueueMessage) then you need to call JLog::add and pass the category as jerror.
 
The category is the third param so it would be:
 
JLog::add("Some message here",JLog::INFO,"jerror");
 
 
In particular this bit:
 
Adding the category of jerror means that this message will also be displayed to users
 
 
Cheers,
Eric.
Message has been deleted

PGS

unread,
Nov 17, 2015, 2:38:28 AM11/17/15
to Joomla! General Development
I tried your suggestions but nothing changed.
I still get the same error: "Error displaying the error page: Application Instantiation Error: Application Instantiation Error" .
Only if I remove line 'JLog::add' the error goes away.
Reply all
Reply to author
Forward
0 new messages