Programmatically find PHP error log file

I know that the PHP log file is located in /var/log/nginx/error.log for my personal window, but I am interested in pragmatically finding out where the error log file is.

I tried:

  ini_get('error_log'); 

But my php ini does not indicate error_log, so it is empty. And since apache / ngnix stores different places, is there a way to find out where the errors are written? I don't mind using exec() to run a command to get it, but

 php -i | grep error_log 

Returns

 error_log => no value => no value 

For my setup

+2
source share
2 answers

Find Command Line Error Log File Using PHP:

 php -i | grep error_log 

To find the error log file for the web server - use the built-in function:

 phpinfo(); 

Remember, that:

error_log string

The name of the file where the scriptlog errors should be. The file must be writable by the web server user. If the special syslog value is used, errors are sent to the system logger instead. On Unix, this means syslog (3), and on Windows NT, it means Event Log. System Logger is not supported on Windows 95. See Also: System Log (). If this directive is not set, errors are sent to the SAPI error logger. For example, this is the error log in Apache or stderr in the CLI. See also error_log ().

So, when you get error_log => no value => no value , this means that the log for Apache / ngnix will be used - as in your configuration.

More information on setting error_log php.ini can be found here.

+1
source

You need phpinfo()

unfortunately, it outputs, but does not return the required information, but on this page quite a lot of people presented examples of extracting output

0
source

Source: https://habr.com/ru/post/923322/


All Articles