Last Updated: February 25, 2016
·
1.013K
· madhugb

Adding custom logger : apache

function logger($message, $data)
{
  $path = '/path/to/your/custom_file.log';
  if (!file_exists( $path ))
  {
    touch($path);
  }
  error_log( print_r($message, TRUE) . " : ". 
              print_r($data, TRUE) , 3, $path);
  return true;
}

You can use the function as below

logger(array('test'=> 'logger'));
logger("test", array('1'=> 'test1', '2'=> 'test2'));

and to see the debugging messages type the following in terminal

tail -f /path/to/your/custom_file.log