Resources
Apache turn on logging, Access.log
Description of LogLevel instructions in Apache configuration file
Apache Official document Apache logs
About error Log
When the project was tested on a test server today, a request returned a 500 status code, and the Web server was using Apache, and the Apache error log was found, but the log was discovered to be empty. It's so weird.
Later, the data, found that the error record is a level of other
| Level
Description |
Example |
emerg |
Emergencies-system is unusable. Emergency; The server is not available |
"Child cannot open lock file. Exiting " |
alert |
Action must be taken immediately. Must take action immediately |
"Getpwuid:couldn ' t determine user name from UID" |
crit |
Critical Conditions. Critical situation |
"Socket:failed to get a socket, exiting child" |
error |
Error conditions. Errors occurred |
"Premature end of script headers" |
warn |
Warning conditions. Warning |
"Child process 1234 do not exit, sending another SIGHUP" |
notice |
Normal but significant condition. OK, but there's a situation to note |
"Httpd:caught Sigbus, attempting to dump core in ..." |
info |
Informational. General Information |
"Server seems busy, (you could need to increase startservers, or min/maxspareservers) ..." |
debug |
Debug-level messages. Debug level information, including module run status |
"Opening config file ..." |
This error level is recorded in the Apache configuration file httpd.conf or in the virtual host configuration file
Errorlog "Logs/error_log" # # Loglevel:control the number of messages logged to the error_log.# Possible values Include:de Bug, info, notice, warn, error, crit,# alert, Emerg. #LogLevel Alert
Among them, loglevel specified the lowest level of error to record, my company this test server was alert, too high, causing a lot of errors will not be recorded, so I set to info, restart Apache, and then reproduce the error, finally found the cause of the error in Error_log :
[Tue Jul 25 17:33:06.476703 2017] [: ERROR] [PID 2316:tid 3328] [Client 113.47.63.8:49522] PHP Fatal Error:
Referer:http://www.xxxx.com/awap/advertiser/register
Originally PHP reported the wrong, later chase the project source code, found that PHP returned 500 of the status code.
So why would Apache's error_log record PHP errors, as the Apache document says:
Any information written to stderr by a CGI script would be copied directly to the error log.
PHP as a CGI script, its standard error (STDERR) was copied and placed in the Apache error log.
Apache recommended the lowest level for Crit, specific settings for which, or according to their own needs to set it!
About Access_log
Here are my notes, probably recorded, please check the article header link
Related Modules:mod_log_config mod_setenvif
Related Directives:customlog logformat setenvif
Access log functions: Access log records all requests that have been processed by the server.
The storage path and contents of access log are controlled by the customlog instruction.
Use the Logformat directive to simply specify the items that need to be displayed in the content.
For example, in the yellow area of the code below, Customlog specifies the storage path for access log
<VirtualHost*:80>LogLevel Info documentroot "E:\qprwork\project" errorlog "Logs/myapp.com-error.log" customlog "Logs/myapp.com-access.log" combined ServerName myapp.com<Directory"E:\qprwork\project">Options Indexes followsymlinks allowoverride all Order allow,deny</Directory> </VirtualHost>
What's that combined? He was telling log the format of the record. This is about Logformat.
Logformat directive is divided into two parts, the first part is the format, the second part is nickname,
The following excerpt from httpd.conf, Blue is Logformat, where the left percent semicolon that string is the format, the right combined is nickname
<IfmoduleLog_config_module># # The following directives define some format nicknames for use with # a CUSTOMLOG directive (see below). # Logformat "%h%l%u%t \"%r\ "%>s%b \"%{referer}i\ "\"%{user-agent}i\ "" Combined Logformat "%h%l %u%t \ "%r\"%>s%b "common<IfmoduleLogio_module># need to enable MOD_LOGIO.C to use%I and%O Logformat "%h%l%u%t \"%r\ "%>s%b \"%{referer}i\ "\"%{user-agent}i\ "%I%O" Combinedio</Ifmodule># # The location and format of the access logfile (Common logfile format). # If You don't define any access logfiles within a<VirtualHost># container, they'll be logged here. Contrariwise, if you *do* # define per-<VirtualHost>access LogFiles, transactions'll be # logged therein and *not* in the this file. # customlog "E:/wamp/logs/access.log" Common # # If you prefer a logfile with access, agent, and Referer Informat Ion # (Combined Logfile Format) You can use the following directive. # #CustomLog "Logs/access.log" combined</Ifmodule>
When customizing Customlog, you can use nickname to specify the format you want, such as Customlog "Logs/myapp.com-access.log" in the code snippet above combined
The following is an Apache Access_log fragment
"mozilla/5.0 (Windows NT 6.1; Win64; x64) applewebkit/537.36 (khtml, like Gecko) chrome/59.0.3071.115 safari/537.36 "
Apache LOG: Error_log,access_log