Nginx error log (error_ Log) configuration and information explanation

Nginx error log (error_log) configuration and information detail
Nginx software will record the fault information of its own operation and log information of user access to the specified log file.
Nginx error log information is introduced
Nginx error message is an important means of debugging Nginx service, belongs to the core function module (NGX_core_module) parameter, the name of the parameter is error_log, can be placed in the Main block global configuration, can also be placed in a different virtual host to separate the virtual host error message
The default value of error_log:

# error_log logs/error log the error;

The syntax format and parameter syntax of error_log are described as follows:

Error_log & lt; FILE> & lt; LEVEL>;
Keyword log file error log level
 
Keyword: Where the keyword error_log cannot be changed
Log file: You can specify any directory where you want to store logs
Error log level: the common error log level is [debug | info | notice | warn | error | crit | alert | emerg], the higher the level is, the less information will be recorded.
The production scenario is generally one of the three levels of warn | error | crit

Note: Do not configure the lower levels of the INFO level, which can cause significant disk I/O consumption.
The tag segment location of the error_log parameter:

main, http, server, location

Reference data: http://nginx.org/en/docs/ngx_core_module.html#error_log
The Nginx configuration error logging procedure is described
(1) Insert the error_log statement

vi conf/vhost/www.abc.com.conf
# VI edit the virtual host configuration file

Document Contents:

server {
Access_log/data/log/WWW.
Listen, 80;
Server_name abc.com www.abc.com;
The location/{
The root/data/WWW/WWW.
The index index. HTML index. HTM;
}
Error_log logs/error_www.abc.com.log error;
# New content ↑
}

(2) Restart the service
After confirmation, you can restart the machine. The operation is as follows:

nginx -t
# results show that OK and Success are ok and can be restarted
nginx -s reload

(3) Check the error log file

ll logs/error_www.abc.com.log
-rw-r–r– 1 root root 2305 Jun 13 18:25 logs/error_www.abc.com.log

Check to see if the file is produced and the configuration is successful.

Read More: