Apache log file name and path introduction (Recommended learning: apache use)
When we install and start Apache Afterwards, Apache will automatically generate two log files, which are the access log access_log (access.log on Windows) and the error log error_log (error.log on Windows).
If you use SSL service, there may also be three log files: ssl_access_log, ssl_error_log and ssl_request_log.
The path of the log file varies depending on the installation method. It is generally in the logs subdirectory of the Apache installation directory. The path of the log file can be found in the Apache configuration file according to the actual installation situation.
How to read server logs
During server maintenance, you often encounter various errors. Constantly check the server logs to easily know where the error is. problem. Use ssh to remotely connect to the server, and then enter the following command to dynamically display the last few lines of the error log for easy troubleshooting.
tail -f /usr/local/apache/logs/error_log
No matter which method is used, it is a good practice to open multiple terminal windows at the same time: for example, display the error log in one window and the access log in another window. This way we are always informed of what is happening on the site and can address it immediately.
There is a lot of information that can be recorded in log files, including:
(1) The address of the remote machine: "Address of the remote machine" and "Who is browsing Website" is similar, but not the same.
(2) Browsing time: When did the visitor start visiting the website? We can learn a lot from the answer to this question. The information that can be obtained from a single access record is very limited, but if we start from thousands of access records, we can get very useful and important statistical information.
(3) Resources visited by users: Which parts of the website are most popular among users? These most popular parts are the ones we should continue to develop. What parts of your website always get the short end of the stick? Maybe these neglected parts of the site are too hidden, or maybe they really aren't interesting, and we need to find ways to improve them. Of course, there are other contents on the website, such as legal statements, that although few people visit, they should not be changed casually.
(4) Invalid links: Of course, log files can also tell us what things cannot run as we imagined. Are there bad links in the website? Did you get the wrong URL when linking from other websites? Are there any CGI programs that don't work properly? Is there a search engine crawler that makes thousands of requests per second, thus affecting the normal service of this website? The answers to these questions can be found in the log files.
The above is the detailed content of How to read logs in apache. For more information, please follow other related articles on the PHP Chinese website!