Log Files
We are provided with the JLog class that is specifically for handling log files. In order
to use this class we must first import it:
jimport('joomla.utilities.log');
We'll start by exploring the use of JLog to handle the global error log file. The global
error log file is a PHP file normally located in the logs. A common use of this file is to
log failed login attempts.
To get a JLog object to handle the global error log file we use the getInstance()
method:
$errorLog =& JLog::getInstance();
Utilities and Useful Classes
[ 362 ]
Next we will add a new entry to the log file. New entries are appended to the end
of the log file and they are derived from associative arrays. The keys required in the
array differ dependent on the log file we are handling. For the global error log file we
can use the following keys:
DATE
TIME
LEVEL
C-IP
STATUS
COMMENT
If we do not provide values for the DATE, TIME, or C-IP keys, they are automatically
populated. We are not required to provide any key-value pairs; however, this would
make the log file relatively useless.
Pages:
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504