Overview
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/example.com/http directory.
- 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
DreamPress Plans Only
You do not need to include http/s in the file path (as mentioned in the following examples) to view the log files for DreamPress sites. You can find DreamPress-related log files using the /exampleuser/logs/example.com file path instead.
- 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.
[server]$ cd example.com
- cd into the domain's /http folder.
[server]$ cd http
- Type in the following to view a list of your log files:
[server]$ ls
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:
Command | Description |
---|---|
[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"
The 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"