Working with PHP requires you to consider how to handle errors. The errors can be various kinds and have different consequences for the code execution, and have to be handled accordingly. Errors are generally speaking scenarios where the code encounters a problem because of a given scenario that does not meet the criteria and expectations given by the code. There is no way you can expect to develop a script that never encounters errors, and therefore you should put proper care into your error handling process. If not, then users may experience odd and unexpected behaviour which frustrates and leads to lower satisfaction. More severely it may even lead to broken data and unusable databases.
Basically, PHP errors are logged in php error log and this is useful to find the exact cause of errors for your php files. Here are the steps how you can fetch the error log via your Servage account file manager and via your Servage account SSH account:
1) Filemanager
- Open your Servage control panel and go to Click the menu > Files > File Manager
Please refer to this useful article from our knowledge base using which you can easily do this:
https://helpdesk.servage.net/908198-How-to-adminstrate-your-files-with-the-help-of-the-Servage-FileManager
- Browse to the domain name folder throwing the error
- Find and open the ‘logs’ folder
- Scroll below to find “php-error.log” file
You can open this file in File Manager. The latest log entry is at the bottom of the file. You can check the error messages to find the cause of php error. This is useful when you encounter unknown errors for your php scripts. In case the php-error.log is large, you may face difficulty opening it in File Manager. Please use SSH method to view the log in such a situation.
2) SSH
- Log into your ssh account.
Please refer to this useful article from our knowledge base using which you can easily do this:
https://helpdesk.servage.net/781340-Your–SSH-account
- Navigate to the domain name and the logs folder. Here are the commands:
cd <<Domain name>>
cd logs
Here you can see lots of log files. You can open ‘php-error.log’ using nano editor to view its contents, eg: nano php-error.log
- Ctrl + V to reach the end of file to view the latest entry
In case you wish to tail the log to see the the logs being generated as it happens, please use this command:
- tail -f php-error.log
Then run the php page in browser and then view the output of the tail command. A new line should get appended to the log as the error is generated. That should help you find the exact log report of the error message.
Once done, use Ctrl + C to end the running of the command and close the tail’ing of the log file.
No comments yet (leave a comment)