Skip to main content
How to View Application Logs via SSH/SFTP

In this post, you will learn about viewing your application's Access and Error logs by remotely connecting to the server via SSH or SFTP.

Emmad avatar
Written by Emmad
Updated over a week ago

Table of Contents

In this article, you will learn about viewing your application's Access and Error logs by remotely connecting to the server via SSH or SFTP. Here, access logs refer to the logs of Apache (for dynamic requests such as PHP requests), Nginx (for static assets such as images/JS/CSS), and PHP (detailed PHP process information such as files/routes, CPU, and memory consumption). On the other hand, error logs refer to the Apache Error Logs containing information about the issues an application encounters. This may include details of errors and warnings that indicate potential problems with an event or application configuration.

Analyzing logs can be beneficial when it comes to debugging, troubleshooting the application-level issues, and maintaining a good website's health because logs provide information about web requests, the status of requests, visitor's IP addresses, viewed pages, user-agent(s), PHP processes, CPU, and memory consumption.

How to View Access & Error Logs

Application logs can also be monitored using the Cloudways Platform but please note that the logs section of the Cloudways Platform will only display the recent 1000 log entries of Apache, Nginx, and PHP individually but if you are looking to view the previous logs as well, then you need to connect to your server via SSH/SFTP and here is how you can do it.

Application logs are maintained in the logs folder of your application directory. First, choose which method you want to use from SSH or SFTP to connect to your server.

1. Using SSH

Let's begin by connecting to the server via SSH to access the logs folder of your application.

Step #1 β€” Initiate Connection

You can connect to your server via SSH in two ways, choose your preferred option from the below options. You can also click on the hyperlink text of bullet points to learn about the procedure of connecting remotely to the server.

Tip

Learn more about SSH why it is used.

In this example, we are using Master Credentials to access the server remotely.

Step #2 β€” Check Logs

Now, you need to navigate to the logs folder of your application by executing the following command:

cd applications/<your_application_name>/logs

Important

Angle brackets are included to highlight the position of your input, so make sure to remove the angle brackets. Click Here to find out where your application name is located.

You will find all the access and error log files of Apache, Nginx, and PHP listed in the logs folder. Therefore, type the listing command to list the application log files.

ls -l

You can view the logs easily using the following command.

tail -f <log-file-name>

2. Using SFTP

Let's begin by connecting to the server via SFTP to access the logs folder of your application.

Step #1 β€” Initiate Connection

You can connect to your server via SFTP using any SFTP client.

Tip:

Learn more about SFTP why it is used.

In this example, we are using Master Credentials to access the server remotely.

We have used the FileZilla client. You will see a similar window after a successful connection, as shown below. Please be advised the pane at the right shows your server data.

Now, you need to go to the logs folder of your application, so navigate to this path /applications/<your-application-name>/logs.

Important

Angle brackets are included to highlight the position of your input, so make sure to remove the angle brackets. Click Here to find out where your application name is located.

Step #2 β€” Check Logs

You will find all the access and error log files of Apache, Nginx, and PHP listed in the logs folder of your application. Therefore, you may download the logs to view them.

That's it! We hope this article was helpful. If you need any help, then feel free to search your query on Cloudways Support Center or contact us via chat (Need a Hand > Send us a Message). Alternatively, you can also create a support ticket.

Did this answer your question?