jayunit100 jayunit100 - 24 days ago 6
PHP Question

Equivalent of PHP error_log for info logs?

hi guys : I use

error_log
for my logging, but Im realizing that there must be a more idiomatic way to log application progress. is there an
info_log
? or equivalent ?

Answer

You can use error_log to append to a specified file.

error_log($myMessage, 3, 'my/file/path/log.txt');

Note that you need to have the 3 (message type) in order to append to the given file.

You can create a function early on in your script to wrap this functionality:

function log_message($message) {
    error_log($message, 3, 'my/file/path/log.txt');   
}