We all know that PHP saves errors in the php_errors.log file.
But this file contains a lot of data.
If we want to register the data of our applications, we need to save them in an arbitrary place.
To achieve this, we can use two parameters in the error_log function.
http://php.net/manual/en/function.error-log.php
We can do this using:
error_log(print_r($v, TRUE), 3, '/var/tmp/errors.log');
Where
print_r($v, TRUE) : writes the file $ v (array / string / object) to the log file. 3 : put the log message in the user log file specified in the third parameter.
'/var/tmp/errors.log' : Custom log file (this path is for Linux, we can specify others depending on the OS).
OR, you can use file_put_contents()
file_put_contents('/var/tmp/e.log', print_r($v, true), FILE_APPEND);
Where:
'/var/tmp/errors.log': Custom log file (this path is for Linux, we can specify another depending on the OS). print_r($v, TRUE) : writes the file $ v (array / string / object) to the log file. FILE_APPEND: a constant parameter indicating whether to add to the file, if it exists, if the file does not exist, a new file will be created.
Pupil Oct 09 '15 at 9:58 2015-10-09 09:58
source share