Search code examples
phpapacheerror-logging

How to set different path for php error_log file?


I have very limited access to settings on my server, so I need to manually set ini_set('log_errors', 1); in my scripts. But can I in same way change the path to the error_log file, to have it in my reach?


Solution

  • The manual says it's PHP_INI_ALL, so you can set it at runtime.

    • Notably that'll have no effect to any messages generated prior calling ini_set.

    • Better option would be to use one of the SAPI-dependant configuration schemes (.user.ini or .htaccess)

    Also take in mind that the destined log path needs to be writeable by the Apache or FPM process, of course.