OpenLiteSpeed is a lightweight, open-source web server developed by LiteSpeed Technologies. It offers high performance and scalability, making it a popular choice for web applications and websites. Understanding how to configure and analyze OpenLiteSpeed’s logging system is essential for monitoring server performance, troubleshooting errors, and ensuring security.
OpenLiteSpeed maintains two main types of logs:
- Access Logs – Record details of incoming HTTP requests.
- Error Logs – Capture server-side errors, application issues, and warnings.
This guide will walk you through configuring, understanding, and using these logs to optimize your OpenLiteSpeed server.
Log & Configuration File Locations
Before diving into the details, it’s important to know where OpenLiteSpeed stores its logs and configuration files.
Description | Location |
---|---|
Access Logs | /usr/local/lsws/logs/access.log |
Error Logs | /usr/local/lsws/logs/error.log |
Virtual Hosts Logs | /usr/local/lsws/Example/logs/ |
Configuration Files | /usr/local/lsws/conf/httpd_config.conf |
Understanding OpenLiteSpeed Access Logs
What Are Access Logs?
Access logs capture details of all incoming HTTP requests processed by OpenLiteSpeed. These logs provide valuable insights into:
- Visitor behavior and traffic sources
- Frequently accessed pages and resources
- Potential security threats, such as suspicious IP addresses or user agents
Configuring Access Logs
OpenLiteSpeed stores access logs in a central location by default. To enable or configure access logs, follow these steps:
- Access the Web Admin Console (usually accessible at
http://<your-server-ip>:7080
). - Navigate to Server Configuration > Log.
- Configure the Access Log File path and rotation settings.
Sample Configuration:
Access Log File: /usr/local/lsws/logs/access.log
Log Format: %h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"
Access Log Format
OpenLiteSpeed uses a format similar to the Apache combined log format:
%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"
Sample Access Log Entry:
192.168.1.20 - - [14/Nov/2024:10:15:23 +0000] "GET /index.html HTTP/1.1" 200 4523 "https://example.com" "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
Field | Description |
---|---|
%h | Client IP address |
%l | Identd logname (usually ‘-‘) |
%u | Authenticated user (if any) |
%t | Timestamp of the request |
"%r" | HTTP method, path, and protocol |
%>s | HTTP status code |
%b | Response size in bytes |
"%{Referer}i" | Referrer URL |
"%{User-Agent}i" | Client’s browser information |
Understanding OpenLiteSpeed Error Logs
What Are Error Logs?
Error logs capture server-side issues, such as misconfigurations, application errors, or problems with backend servers. These logs are crucial for identifying and troubleshooting server issues.
Configuring Error Logs
To configure error logs in OpenLiteSpeed:
- Open the Web Admin Console.
- Go to Server Configuration > Log.
- Set the Error Log File path and define the Log Level.
Sample Configuration:
Error Log File: /usr/local/lsws/logs/error.log
Log Level: WARN
Error Log Levels
OpenLiteSpeed supports multiple error log levels:
Level | Description |
---|---|
ERROR | Critical errors that need immediate attention |
WARN | Warnings that may indicate potential issues |
NOTICE | Significant but non-critical events |
INFO | General informational messages |
DEBUG | Detailed debug information for troubleshooting |
Sample Error Log Entry
An example of an entry in the OpenLiteSpeed error log:
2024-11-14 10:16:45.123 [ERROR] [192.168.1.20:54321] File not found: /var/www/html/missingfile.php
Explanation:
- The error indicates that the requested file
/var/www/html/missingfile.php
could not be found for the client IP192.168.1.20
.
Common Error Types
Some typical OpenLiteSpeed error messages include:
Error Message | Description |
---|---|
File not found | The requested resource could not be found |
Permission denied | The server does not have permission to access the file |
503 Service Unavailable | The server is overloaded or the backend is down |
Connection reset by peer | The client closed the connection prematurely |
Configuring Logs for Virtual Hosts
OpenLiteSpeed allows you to configure separate logs for different virtual hosts. This is useful if you are hosting multiple websites on the same server:
- Navigate to Virtual Hosts in the Web Admin Console.
- Select the virtual host you want to configure.
- Under the Log section, set the paths for both Access Log and Error Log.
Example Configuration for a Virtual Host:
Access Log: /usr/local/lsws/Example/logs/example.access.log
Error Log: /usr/local/lsws/Example/logs/example.error.log
Log Level: WARN
This configuration allows you to maintain separate logs for each website, making it easier to troubleshoot and monitor individual sites.
Mastering OpenLiteSpeed logs is essential for maintaining server performance, optimizing security, and troubleshooting issues. By effectively configuring and analyzing access and error logs, you can gain valuable insights into your server’s operations and visitor behavior.
Use this guide to enhance your OpenLiteSpeed logging setup and improve your server management skills.