On a poorly protected server, yes. But on most servers there are two users: apache and [you]. You do not have access to the server logs, because they belong to the apache user (or no matter which server you use).
However, you could try:
echo file_get_contents('/var/log/httpd/error_log');
Note. This is the default location on the Apache server based on RedHat. It could be different
Refresh To reflect an updated question
No, you cannot view the error log using error_log
- this is a one-way process that is processed by the web server. It only writes a journal, but you cannot read it.
You can probably display errors:
ini_set('display_errors', 'On'); error_reporting(E_ALL);
You can even use set_error_handler
to handle all warnings and notifications (for example, to send them). But thatโs almost all you can do.
Tom van der woerdt
source share