Is there a way to make PHP log exception (as by default) if custom exception handler was executed?
No, not from what PHP offers (e.g. return FALSE in the callback).
If no, is there a way to log into main php error log file?
Yes, you can use the error_logDocs function for that. The ExceptionDocs should contain the message as well as code, file name and line number.
It also is stringable and error_log() adds the delimiting newline character, so it directly works in logging (it will even downsize based on log_errors_max_len configured size):
set_exception_handler(function ($throwable) {
error_log((string)$throwable);
});
Or less verbose:
set_exception_handler('error_log');
Demo/Playground: https://3v4l.org/s41Vn
Another more or less dirty trick is to create an exception capturing object that remains in memory all the time. If it captures an uncatched exception, it will handle it and store it. In case of destruction (at the end of the process) it can re-throw it. Then PHP needs to deal with it and probably logs it. However I would consider that experimental and also perhaps short-sighted as there can be only one exception handler and it catches uncaught ones, so there is not much way to continue (more shutdown function material perhaps).