jayunit100 jayunit100 - 10 months ago 58
PHP Question

Equivalent of PHP error_log for info logs?

hi guys : I use

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

Answer Source

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');