How to configure error logs with Nginx?
You can find Nginx configurations on nginx.conf file.
# Default locaction in mac if you have installed it through homebrew:
/usr/local/etc/nginx/nginx.conf
# Possible locations on Unix or Linux
/etc/nginx/nginx.conf
/opt/nginx/conf/
|
NGINX writes information about encountered issues of different severity levels to the error log. The error_log
directive sets up logging to a particular file, stderr, or syslog and specifies the minimal severity level of messages to log.
By default, the error log is located at logs/error.log (the absolute path depends on the operating system and installation),
and messages from all severity levels above the one specified are logged.
The configuration below changes the minimal severity level of error messages to log from error to warn:
In this case, messages of warn, error crit, alert, and emerg levels are logged.
error_log logs/error.log warn;
|
The default setting of the error log works globally. To override it, place the error_log directive in the main
(top-level) configuration context. Settings in the main context are always inherited by other configuration levels.
The error_log directive can be also specified at the http, stream, server and location levels and overrides the setting
inherited from the higher levels. In case of an error, the message is written to only one error log, the one closest to the
level where the error has occurred. However, if several error_log directives are specified on the same level, the message are
written to all specified logs.
|