error_log is not working as expected in functions.php file

I had a similar problem: calling error_log() from wp-config.php works, but calling it from functions.php does not work for me.

I couldn’t solve this issue but I’ve found a workaround that allowed me to do some sort of debugging at least. I gave up on error_log() and just wrote an own function that logs into a given file:

function mylog($txt) {
    file_put_contents('/home/myuser/logs/mylog.txt', $txt.PHP_EOL , FILE_APPEND | LOCK_EX);
}