Function to add the Error Log into Custom Log File in Joomla 3.0
function addErrorToLog($message='') { $data = date('Y-m-d H.i.s'). "\t INFO \t\t ".$_SERVER['REMOTE_ADDR']." \t\t Message: ".$message; $log_path = JFactory::getApplication()->getCfg('log_path'); $logfile_path = $log_path . '\com_locator.formbridge.log.php'; if ( !file_exists($logfile_path) ) // if file is not exist. { $ini_data = "#\n" . "#\n" . "#Date: 28.02.2014 13:46:29 UTC\n" . "#WebApp: Form Bridge (Joomla Platform) 1.0 Stable [ IRC Adhikari ] 28.02.2014 00:00 GMT\n\n". "#Fields: date time \t priority \t clientip \t category : message\n"; $error = file_put_contents($logfile_path, (PHP_EOL . $ini_data . $data) ); } else // If file already exist, add the data into existing file. { $error = file_put_contents($logfile_path, (PHP_EOL . $data), FILE_APPEND | LOCK_EX); } return true; } $this->addErrorToLog($message=' This is test message ');