简体   繁体   中英

Using error_log to debug a php file

I have a PHP file that runs ever hour on my server. I want to do some debugging by sending the value of certain variables to my e-mail address or a log file. I tried adding the following test code, but I'm not receving e-mails or finding the log file

error_log("Test 123", 1, "me@mydomain.com");
error_log("Test 123", 3, "/tmp/my_errors.log");

I'm not sure what I need to initialize in my php.ini file or elsewhere to make this work.

You should change the second parameter accordingly. Try using 0, that would write to the default error log file.

error_log("Test 123", 0);

For message_type == 1 you need to make sure that sending e-mails work on your server, and that the 'extra_headers' parameter is set.

For message_type == 3 make sure that php can write to this file.

http://php.net/manual/en/function.error-log.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM