This post will show you how to see your error log using SSH, which will require some basic shell terminal knowledge. Instead, read the following article for an easier way to use FTP:
Using SFTP to view your access and error logs
You may need to inspect your site’s error logs and access logs for troubleshooting reasons to learn more about why an issue occurred. This post will show you how to access these logs using SFTP and Shell.
You must log in to your server and navigate to the logs/example.com/http directory to examine the logs.
Every night, logs are rotated so that access.log and error.log only contain logs from today, whereas error.log.0 and access.log.0 have logs from the previous day.
Because log files are quickly lost after this, it’s best to review them as soon as possible.
GreggHost keeps HTTP logs for three days by default, as required by GDPR.
Viewing logs via SSH
Instructions on how to log in to your server can be found in the SSH overview article.
To change your directory to your user’s /logs directory, use the following:
cd to /logs
To see all of the domains under the user’s control, type in the following:
ls -la $
cd into the domain folder of your choice.
[server]$ cd example.com cd into the /http subdirectory of the domain.
$ cd http [server]
To get a list of your log files, type in the following:
$ ls [server]
Decompressing files that end with .gz
The extension of older log files is.gz, which indicates that they are compressed. Instructions on how to decompress those files can be found in the following article:
Decompress a .gz file
Reading the most recent errors using the ‘tail’ command
The following examples illustrate how to read specific parts of the log using the tail command from within the proper directory.
To read the last lines of a file, use the tail command. Consider the following scenario:
$ tail -n 10 error.log [server]
The latest ten lines of an error log are displayed.
$ tail -f error.log [server]
On the shell, it displays all freshly added lines from a log file in real-time.
more | [server]$ tail -n 100 error.log
Using the more command, displays the last 100 lines one at a time.
This is useful for displaying more lines than your shell window will allow.
To see the next line, press the space bar.
Ctrl + C closes the tail window and returns you to the command line.
Searching for a specific term using the “grep” command
The grep command can be used to search for a certain term within a file. This is especially useful because going through an error log might be tiresome if only a few problems need to be viewed while others can be ignored.
For instance, if you only wanted to examine errors relating to Testing2.jpg, you could use the following command:
$ grep “Testing2.jpg” in error.log
The cat error.log command displays the contents of the log. Several entries may display “File does not exist,” which is often unimportant and can be disregarded. However, you should always double-check that this is the case; if you’re certain they’re unimportant, use the following command: