Locating and Understanding Servebolt Logs

This article provides an overview of Servebolt’s default logging system. For each site hosted on Servebolt, a dedicated /logs/ directory is located in the root directory.. The logs hold valuable insights into your site’s activities, recording detailed information about HTTP requests, errors, and PHP slowlogs. By the end of this article, you’ll have the knowledge to navigate and extract valuable information from your log files. Let’s dive in!

Why Checking Logs is Important

In the event of any unforeseen occurrences or if your site crashes, the first step in a debugging process is to examine the logs. Any code executing on your site that triggers a runtime error will generate an error and log it to the error logs. While not all of these errors may directly disrupt your site, consider them subtle failures that occasionally have the potential to do so in the future.

Viewing the /logs/ Directory

You’ll have three options to view the Servebolt logs

After logging into your site via SSH or SFTP, you’ll find the /logs/ directory in the root directory. Navigate to the /logs/ directory, and you’ll find two more folders: /http/ and /php/. The various logs can be viewed directly with CLI using SSH, or you can download them locally to your machine and open the logs with any text editor. Let’s explain the logs.

HTTP Logs

HTTP logs are crucial for monitoring the activity of an Apache web server. They provide detailed information about the requests made to the server, responses returned, and errors encountered during operation. These logs allow administrators to track and troubleshoot issues, optimize performance, and understand how the server interacts with clients. Within this folder, you’ll find AccessLog and ErrorLog files.

AccessLog

The HTTP AccessLog records detailed information about every HTTP request to the Apache web server.

Here is an example of an HTTP request to the AccessLog:

92.148.0.753 - - [13/Oct/2023:14:41:57 +0000] "GET /ok.php HTTP/2.0" 200 20 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36" PHP - IN:681 OUT:140 -

From the example request above, we start with the IP address:

  1. Client IP address.
  2. Timestamp of the request.
  3. Request method (GET, POST, etc.).
  4. Requested URL.
  5. HTTP protocol
  6. Response status code.
  7. Size of the response in bytes.
  8. The referer. It indicates the URL of the web page that referred the client to the requested resource. In the example above, the referer is not specified (“-“).
  9. User-agent string (browser or client information).

ErrorLog

The HTTP ErrorLog records errors, warnings, and issues that can occur at different levels of the server’s operation, helping administrators and developers pinpoint problems swiftly.

The ErrorLog is an invaluable diagnostic tool for identifying and addressing issues related to server configuration, file permissions, request processing, and more.

Types of Errors:

The ErrorLog logs various types of errors, including:

  • Syntax Errors: These indicate problems in the configuration files (e.g., typos or incorrect directives).
  • HTTP Status Codes: Errors such as 404 (Not Found) or 500 (Internal Server Error) related to client requests.
  • Permission Issues: Errors related to file and directory permissions that can affect server functionality.
  • Module-Related Errors: Issues caused by loaded Apache modules.

Here is an example of an HTTP Error:

[Fri Oct 13 14:57:37.305274 2023] [core:alert] [pid 1700530:tid 1700590] [remote 92.148.0.753:40400] /cust/0/trying_8617/trying_1276/site/public/.htaccess: Invalid command 'my_wrong_directive', perhaps misspelled or defined by a module not included in the server configuration

PHP Logs

PHP logs record the events and errors associated with executing PHP scripts per Bolt environment. These logs provide insight into PHP-specific issues, helping developers debug code, trace errors, and improve the site’s stability and functionality. Within this folder, you’ll find AccessLog and ErrorLog files.

AccessLog

The PHP AccessLog is a feature that allows monitoring and analysis of incoming HTTP requests and their corresponding responses when PHP scripts are executed via PHP-FPM.

The log entries typically include information such as:

  • Timestamp of the request.
  • Request duration.
  • Request method (GET, POST, etc.).
  • Requested URL.
  • Response status code.
  • Script file or resource being accessed.

Here is an example of a request in the PHP AccessLog:

"13/Oct/2023:14:29:58 +0000" 2048 97.415 "GET /info.php" 200 /cust/0/trying_8617/trying_1276/site/public/info.php

ErrorLog

The PHP ErrorLog is a log file that contains errors, warnings, and other informational messages generated by PHP scripts during their execution. The ErrorLog will contain errors such as:

Fatal PHP Errors: These errors can prevent a site from loading. They often indicate a critical problem in the code that cannot be ignored.

PHP Warnings: Warnings, while allowing the site to load, signal potential issues that need attention. They can be related to missing functions or incorrect callbacks.

Stack Traces: Some fatal PHP errors provide stack traces, which are valuable for troubleshooting complex applications with multiple files. The stack trace error is a type of error that gives you a list of related function calls, from start to finish. You can use this list of associated functions, add logging, and determine where the error originated.

Session-Related Errors: These errors are often related to session issues, which are commonly used for logins, shopping carts, and search results on a site.

File and Path Errors: Errors related to missing files or incorrect paths in the code can lead to functionality problems.

Memory Limit Exceeded: When the PHP memory limit is exceeded, it can lead to errors, often due to outdated code or inefficient scripts. What is PHP memory limit?

Deprecation Errors: Errors related to functions like “mysql_connect” suggest outdated code that is not compatible with newer versions of PHP.

Syntax Errors: Syntax errors indicate issues with the code itself, such as typos or incorrect usage of variables.

Resource Limit Issues: Errors related to resource limits may occur due to factors like a full disk, inode quotas, or size limits.

Here are some examples of errors logged in the ErrorLog:

[13-Oct-2023 14:37:29 UTC] PHP Parse error:  Unclosed '(' on line 5 in /cust/0/trying_8617/trying_1276/site/public/ok.php on line 11
[17-Nov-2023 09:26:43 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function sdefine() in /cust/0/serveb_8661/accele_1356/site/public/wp-config.php:29

PHP Slow Log

The PHP Slow Log is primarily used to identify and analyze sections of PHP code that are causing delays or slow response times in web applications. When an application encounters a script that exceeds a predefined execution time threshold, the PHP Slow Log records detailed information about the script execution, helping developers pinpoint performance issues.

Any PHP script running over 2 seconds will be logged in the slow log.

Additional Logs and Rotation

Slow SQL Query Log

The MySQL slow log shows which database queries take a long time to finish. It consists of SQL statements that take more than 1 second to execute. The slow query log can be used to find queries that take a long time to perform and are, therefore, candidates for optimization.

Our Support Agents can provide a Slow Query Log file upon request. However, this is a manual process for us. These are not auto-generated. If you need a Slow Query Log, please request one in our chat, and we’ll generate one for you.

Git Logs

The Git logs will log all scripts executed during Git deploy events and place them in the /logs/deploy.log file. Alongside the deploy.log file, a repository.log file is created containing information about which Git repository and branch was used. 

Cron Log

All output created by cron is redirected to the cron.log file (~/logs/cron/cron.log), regardless of the notification state in our Admin Panel. The file will contain both the standard output and the standard error of any command on the cronline.

Log Rotation

Our logs are rotated every day and kept for a week. Within our logs, you will find AccessLog and ErrorLog files for the running day and archived and compressed files that go back a full week.

An example of what such a file would look like is AccessLog-20200429.gz

  • 2020 is the year 2020
  • 04 is the month of April
  • 29 is the day the file was initially generated.

If you want more information on how to view and examine log files, check out this article.


And as always, should you have any additional questions please don’t hesitate to contact our support chat at servebolt.com!