Overview
This article explains how to view your website's error logs by logging into the server via SSH. This is sometimes necessary to help troubleshoot any issues your website may be encountering.
This article is for advanced users who have experience running SSH commands. For an easier option using FTP, see this article instead.
Log retention policy
Please note the following:
- 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 7 days.
Prerequisites
This article assumes you have created a shell user and are able to log into your server via SSH.
Viewing logs via SSH
- Log into your server via SSH.
- Change to your user’s /logs directory:
[server]$ cd ~/logs
- View a list of domains under the user:
[server]$ ls -la
- Change into the desired domain's directory.
[server]$ cd example.com
- Change into the directory where the logs are located.
- Change into the http directory (If your website is not using an SSL certifcate).
- Change into the https directory if it's using an SSL certificate).
-
[server]$ cd https
DreamPress Plans Only
You do not need to include http/s in the file path to view the log files for DreamPress sites. You can find DreamPress-related log files using the ~/logs/example.com file path instead.
- View a list of your log files:
[server]$ ls -la
Decompressing files that end with .gz
Older log files are compressed and end with .gz. See this article for instructions on how to decompress these files.
How to analyze and search the logs
The following sections explain how to read and search through the log files.
Reading the most recent errors
The table below shows various uses of the tail command you can run to read the last lines from a file.
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
You can use the grep command to quickly search for a specific term within your log files.
For example, run this command if you only want to see errors related to the Testing2.jpg file.
[server]$ cat error.log | grep "Testing2.jpg"
Remove common errors
Error log files often contain entries with the text "File does not exist".
You should always first confirm if these are relevant to your site. If not, you can easily remove them from your searches using the grep -v command. For example, this command removes all log entries with this error.
[server]$ cat error.log | grep -v "File does not exist"