#Apache server logs provide detailed information that helps detect common problems with the server. To log access to a website, mod_log_configmodule must be enabled.
There are three instructions in the apache configuration file, namely -
TransferLog: Create a log file. (Recommended learning: Apache server)
LogFormat: Specify a custom format.
CustomLog: Create and format log files.
The TransferLog directive is available in the apache configuration file, which rotates the virtual host log files according to the set parameters.
VirtualHost www.example.com><br/><br/> ServerAdmin webmaster@yiibai.com<br/> DocumentRoot /usr/www/example/httpd/htdocs/<br/> ServerName www.example.com<br/> ServerAlias example.com www.example<br/> ErrorLog /usr/www/example/httpd/logs/error_log<br/> TransferLog /usr/www/example/httpd/logs/accesslog<br/> CustomLog /usr/www/example/httpd/logs/accesslog combined<br/><br/></VirtualHost><br/>
Two types of Apache log formats
Common log format
Combined log format
They can be enabled by editing the apache configuration file, which is the apache2.conf (Debian/ubuntu) or httpd.conf (rpm-based systems) file.
General log format
LogFormat "%h %l %u %t \"%r\" %>s %b" common<br/>CustomLog logs/access_log.log common<br/>
The general log content examples generated by Apache are as follows
[Wed Oct 11 14:32:52 2000] [error] [client 127.0.0.1] client denied by server configuration: /export/home/live/ap/htdocs/test<br/>
Combined log format
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined<br/>CustomLog log/access_log.log combined<br/>
In the above format,
%h is the remote host
%l is the identity of the user determined by identd
%u is the user determined by HTTP authentication Name
%t is the time it took for the server to finish processing the request.
%r is the request line from the client ("GET/HTTP/1.0").
%> s is the status code sent from the server to the client (500, 404, etc.)
%b is the size of the client response (in bytes) Referer is the link to this URL page.
The user agent is the browser identification string.
Combined logs generated by Apache:
199.180.11.91 - - [06/Mar/2019:04:22:58 +0100] "GET /robots.txt HTTP/1.1" 404 1228 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)"<br/>
Custom logs create separate log files for each virtual host on the server. It needs to be specified in the virtual host section of the configuration file.
You can see the virtual host configuration mentioned below, the generated log will be customized for that virtual host, and the format will be combined.
The above is the detailed content of How to record logs on Apache server. For more information, please follow other related articles on the PHP Chinese website!

The core function of Apache is modular design and high customization, allowing it to meet various web service needs. 1. Modular design allows for extended functions by loading different modules. 2. Supports multiple operating systems and is suitable for different environments. 3. Multi-process, multi-threaded and event-driven models improve performance. 4. The basic usage includes configuring the virtual host and document root directory. 5. Advanced usage involves URL rewriting, load balancing and reverse proxying. 6. Common errors can be debugged through syntax checking and log analysis. 7. Performance optimization includes adjusting MPM settings and enabling cache.

What makes Apache still popular in modern web environments is its powerful capabilities and flexibility. 1) Modular design allows custom functions such as security certification and load balancing. 2) Support multiple operating systems to enhance popularity. 3) Efficiently handle concurrent requests, suitable for various application scenarios.

The reasons why Apache has developed from an open source project to an industry standard include: 1) community-driven, attracting global developers to participate; 2) standardization and compatibility, complying with Internet standards; 3) business support and ecosystem, and obtaining enterprise-level market support.

Apache's impact on Webhosting is mainly reflected in its open source features, powerful capabilities and flexibility. 1) Open source features lower the threshold for Webhosting. 2) Powerful features and flexibility make it the first choice for large websites and businesses. 3) The virtual host function saves costs. Although performance may decline in high concurrency conditions, Apache remains competitive through continuous optimization.

Originally originated in 1995, Apache was created by a group of developers to improve the NCSAHTTPd server and become the most widely used web server in the world. 1. Originated in 1995, it aims to improve the NCSAHTTPd server. 2. Define the Web server standards and promote the development of the open source movement. 3. It has nurtured important sub-projects such as Tomcat and Kafka. 4. Facing the challenges of cloud computing and container technology, we will focus on integrating with cloud-native technologies in the future.

Apache has shaped the Internet by providing a stable web server infrastructure, promoting open source culture and incubating important projects. 1) Apache provides a stable web server infrastructure and promotes innovation in web technology. 2) Apache has promoted the development of open source culture, and ASF has incubated important projects such as Hadoop and Kafka. 3) Despite the performance challenges, Apache's future is still full of hope, and ASF continues to launch new technologies.

Since its creation by volunteers in 1995, ApacheHTTPServer has had a profound impact on the web server field. 1. It originates from dissatisfaction with NCSAHTTPd and provides more stable and reliable services. 2. The establishment of the Apache Software Foundation marks its transformation into an ecosystem. 3. Its modular design and security enhance the flexibility and security of the web server. 4. Despite the decline in market share, Apache is still closely linked to modern web technologies. 5. Through configuration optimization and caching, Apache improves performance. 6. Error logs and debug mode help solve common problems.

ApacheHTTPServer continues to efficiently serve Web content in modern Internet environments through modular design, virtual hosting functions and performance optimization. 1) Modular design allows adding functions such as URL rewriting to improve website SEO performance. 2) Virtual hosting function hosts multiple websites on one server, saving costs and simplifying management. 3) Through multi-threading and caching optimization, Apache can handle a large number of concurrent connections, improving response speed and user experience.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Zend Studio 13.0.1
Powerful PHP integrated development environment

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver Mac version
Visual web development tools
