Reputation: 10330
I know that the PHP log file is located at /var/log/nginx/error.log
for my personal box, but I am interested in pragmatically finding out where the error log file is.
I have tried:
ini_get('error_log');
But my php ini doesn't specify error_log, so it's blank. And since apache/ngnix each store different places, is there a way to find out where errors are being written to? I don't mind to use exec()
to run a command to get it, but
php -i | grep error_log
Returns
error_log => no value => no value
For my set up
Upvotes: 4
Views: 849
Reputation: 1668
To find error log file for command line PHP use:
php -i | grep error_log
To find error log file for web server - use build-in function:
phpinfo();
Remember that:
error_log string
Name of the file where script errors should be logged. The file should be writable by the web server's user. If the special value syslog is used, the errors are sent to the system logger instead. On Unix, this means syslog(3) and on Windows NT it means the event log. The system logger is not supported on Windows 95. See also: syslog(). If this directive is not set, errors are sent to the SAPI error logger. For example, it is an error log in Apache or stderr in CLI. See also error_log().
So when You get error_log => no value => no value
it means log for Apache / ngnix will be used - as in Your configuration.
You can find more information about the error_log
php.ini
setting here
Upvotes: 1
Reputation: 15709
You need phpinfo()
unfortunately it outputs rather than returning the information you need - but on that page quite a few folk have given examples of cathing the output
Upvotes: 0