We want to log all output generated by trigger_error()
function calls into an error_log file for later analysis. As our application has a single entry point for both HTTP based requests and console requests, this should ideally be setup within the same file as shown below, e.g. here named error.php
<?php
error_reporting( E_ALL );
ini_set("display_errors", 0);
ini_set("error_log", "test-error.log");
error_log("Msg 1");
trigger_error("Msg 2");
Calling error.php
via the webserver results in correct logging in test-error.log:
[11-Apr-2019 16:02:50 Europe/City] Msg 1
[11-Apr-2019 16:02:50 Europe/City] PHP Notice: Msg 2 in error.php on line 6
Calling error.php via the local shell results in not logging the trigger_error()
call.
[11-Apr-2019 16:05:31 Europe/City] Msg 1
How should we set up error reporting to have php errors from trigger_error()
also within the same log file?