This article explains how to view your error log via SSH which requires some basic knowledge of a shell terminal. For an easier option using FTP, view the following article instead:
For troubleshooting purposes, you may sometimes need to check your site’s error logs and access logs to get more information as to why a problem may occur. This article explains how to view these logs through SFTP and Shell.
- In order to view the logs, you must log in to your server and navigate to the
- Logs are rotated every night so that access.log and error.log only contain today’s logs, while error.log.0 and access.log.0 contain logs from the day before.
- Log files are deleted shortly after this, so it’s recommended to check them as soon as possible.
- Per GDPR, DreamHost stores HTTP logs by default for 3 days.
Viewing logs via SSH
- View the SSH overview article for instructions on how to log in to your server.
- Type in the following to change your directory to your user’s /logs directory:
[server]$ cd ~/logs
- Type in the following to view all of the domains under the user:
[server]$ ls -la
- cd into the desired domain’s folder.
- cd into the domain’s /http folder.
[server]$ cd http
- Type in the following to view a list of your log files:
Decompressing files that end with .gz
Older log files are compressed and end with .gz. View the following article for instructions on how to decompress those files:
Reading the most recent errors using the 'tail' command
The following shows various uses of the tail command that you can run within the appropriate directory to read specific parts of the log.
Use the command tail to read the last lines from a file. For example:
[server]$ tail -n 10 error.log
|Shows the last 10 lines from an error log.|
[server]$ tail -f error.log
|Shows all newly added lines from a log file in real-time on the shell.|
[server]$ tail -n 100 error.log | more
|Shows the last 100 lines a single line at a time using the more command.
|Ctrl + C||Quits tail and returns to the command line.|
Searching for a specific term using the "grep" command
You can use the grep command to search for a specific term within files. This is particularly helpful since looking through an error log can be tedious if a certain errors need to be seen and others can be ignored.
For example, if you only wanted to see errors related to the Testing2.jpg you can run this command:
[server]$ cat error.log | grep "Testing2.jpg"
cat error.log command lists everything within the log. You may notice that several entries show “File does not exist” which are often irrelevant and can be ignored. You should always ensure that this is the case, however; If you’re sure they are not important, filter them out by running the following:
[server]$ cat error.log | grep -v "exist"