Error log

From DreamHost
(Redirected from Error Messages)
Jump to: navigation, search


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.

Dh-kb-note-icon.fw.png Notes:
  • In order to view the logs, you must log in to your server and navigate to the logs/ 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.

Viewing the logs via SFTP

As mentioned previously, the logs are inside the /logs/ directory under your username on the server.

To view the logs:

  1. Make sure your user is an SFTP or Shell user. Visit the Enabling Shell Access article for instructions.
  2. Log into your server using your client. Visit the FTP article for details.
    Once logged in, you’ll see several files; in this example we’re in the dhwikitest users’s directory noted by the ‘Remote site:’ field which shows /home/dhwikitest:
    01 Error Log.fw.png
  3. Click into the /logs directory.
    You then see a list of sites associated with this user:
    02 Error Log.fw.png]
  4. Click into the appropriate site from this next directory.
    03 Error Log.fw.png
  5. Click into the http directory.
    You’ll see the error.log and access.log as of today.
    04 Error Log.fw.png
    Dh-kb-note-icon.fw.png Note: Once in the /http directory, you'll notice that your remote site looks different at the top, which shows that your selected directories have changed – this is fine.

  6. Right click on the log file and open with your text editing program.

Viewing logs via SSH

  1. View the SSH article for instructions on how to log in to your server.
  2. Type in the following to change your directory to your user’s /logs directory:
    cd ~/logs
  3. Type in the following to view all of the domains under the user:
    ls -la
  4. cd into the desired domain’s folder.
  5. cd into the domain’s /http folder.
    05 Error Log.fw.png
  6. Type in the following to view a list of your log 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
tail -n 10 error.log
Shows the last 10 lines from an error log.
tail -f error.log
Shows all newly added lines from a log file in real-time on the shell.
tail -n 100 error.log | more
Shows the last 100 lines a single line at a time using the "more" command.
  • Useful for showing more lines than will fit in your shell window.
  • Press the space bar to view the next line.
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:

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:

cat error.log | grep -v “exist”

See also