Apache turn on logging, Access.log
Found logs folder only Error.log
No access.log.
Modify Httpd.conf
# customlog "Logs/access.log" common remove the previous #
*******************************************************************
Log_format access ' $remote _addr-$remote _user [$time _local] "$request"
' $status $body _bytes_sent ' $http _referer '
' "$http _user_agent" $http _x_forwarded_for ';
Location ~. *\. (gif|jpg|jpeg|png|bmp|swf) $
{
Expires 30d;
Access_log off;
}
Location ~. *\. (JS|CSS)? $
{
Expires 1d;
Access_log off;
}
Access_log/www/logs/9enjoy.com.log access;
The next two ways of Apache:
1. Record only html,htm,php files such as Setenvifnocase Request_uri "(\.htm|\/|\.html|\.php) $" htm
Customlog Logs/9enjoy.com-access_log Combined env=htm
2. Exclusion method: <filesmatch "\. (ICO|GIF|JPG|PNG|BMP|SWF|JS|CSS) ">
SETENV IMAGE 1
</FilesMatch>
Customlog Logs/9enjoy.com-access_log Combined env=! The IMAGE ****************************************************************** Apache runtime records information about all requests it processes. At the same time, Information about abnormal conditions that occur during processing is also logged. The server can record the activity information related to the request in multiple log files in multiple formats, but only one copy of the error message is logged. With respect to the activity record, the log content is not written until the request has been processed. such as uploading a large file, it is written to the log after the file has been uploaded. The error message is written when the error occurs. Of course, mistakes happen for a moment. There is a common way to display logs: CLF (common Log format). The format is: "%h%l%u%t \"%r\ "%>s%b" but with the development, the content of this format is not enough, people have organized another format: "%h%l%u%t \"%r\ " %>s%b \ "%{referer}i\" \ "%{user-agent}i\" It can remember the requested browser version and other client software names and versions. Apache comes with a standard log module: Mod_log_config. In addition, Apache 2.0 comes with an additional module: Mod_logio. It is a reinforced version of the former. and in http:// Modules.apache.org Module Registration Area There are other third-party modules to use. For example, my Apache httpd.conf file has the following configuration: Errorlog "Logs/error.log" LogLevel warn < Ifmodule log_config_module> logformat "%h%l%u%t \"%r\ "%>s%b \"%{referer}i\ "\"%{User-A Gent}i\ "" Combined logformat "%h%l%u%t \"%r\ "%>s%b" common <if Module logio_module> logformat "%h%l%u%t \"%r\ "%>s%b \"%{referer}i\ "\"%{user-agent}i\ "%I%O" Combinedio </IfModule> customlog "Logs/access.log" Common </ifmodule > There are two files in the logs directory under my Apache installation directory, which is the configuration above Error.log and Access.log above defines the log output of Apache error messages. and defines the level of log output. There are several levels:
Rank name |
Introduced |
Emerg |
An emergency; The server is not available |
Alert |
Must take action immediately |
Crit |
Critical situation |
Error |
Error occurred |
Warn |
Warning |
Notice |
Normal, but there is a case to note |
Info |
General Information |
Debug |
Debug level information, including module run status |
When a level is set, it is recorded in the log file, along with the logs of its rank above. However, regardless of the value set, notice level information is always recorded.
format string in log:
format string |
Description |
%% |
Percent semicolon (Apache2.0.44 or later version) |
%a |
Remote IP Address |
%A |
Native IP Address |
%B |
Number of bytes transferred except HTTP headers |
%b |
The number of bytes transmitted in the CLF format except for the HTTP header, which is displayed '-' instead of 0 when no byte is transmitted. |
%{foobar}c |
The content of the Cookiefoobar that is passed to the server in the request. |
%d |
The time, in micro units, that the server takes to process this request. |
%{foobar}e |
The value of the environment variable Foobar |
%f |
Filename |
%h |
Remote host |
%H |
protocol used by the request |
%{foobar}i |
The content of the request header Foobar: sent to the server. |
%l |
Remote login name (from Identd, if supported), unless IdentityCheck is set to "on", a "-" will be obtained. |
%m |
Method of Request |
%{foobar}n |
The contents of the annotation foobar from another module. |
%{foobar}o |
Answer header Foobar: the content. |
%p |
The server serves the standard port for the request. |
%P |
The PID of the child process that served this request. |
%{format}p |
The PID or TID (thread ID) that serves the request, and the format range is: PID and Tid (2.0.46 and later) and Hextid (requires APR1.2.0 and above) |
%q |
The query string, if present, by a "?" Boot, otherwise return an empty string) |
%r |
The first line of the request |
%s |
State. For internal redirection requests, this state refers to the state of the original request,---%>s refers to the state of the last request. |
%t |
Time, in normal log time format (Standard English format) |
%{format}t |
Time, expressed in the format specified by Strftime (3). (localized format by default) |
%T |
The time, in seconds, that the request took to finish processing. |
%u |
Remote user name (based on authentication information, if return status (%s) is 401, may be false) |
%u |
The URL path of the request, which does not contain a query string. |
%v |
Standard servername for service of this request |
%V |
The server name is set according to the USERCANONICALNAME directive. |
%x |
Connection status when the request is complete:
x= |
The connection is interrupted before the answer is complete. |
+= |
Continue to connect after the reply is delivered. |
-= |
Closes the connection after the reply is delivered. |
(in a later version of 1.3, this instruction is%c, but this is the same as the previous SSL syntax:%{var}c conflict) |
%I |
The number of bytes received, including the data for the request header, and cannot be zero. To use this command you must enable the Mod_logio module. |
%O |
The number of bytes sent, including the data for the request header, and cannot be zero. To use this command you must enable the Mod_logio module. |
log request logs by day or hour