error_log

The error_log directive in NGINX specifies the file or location where error messages are logged.

Syntaxerror_log path [level];
Defaulterror
Contextmain
Arguments1+

Description

The error_log directive is fundamental in configuring the logging behavior of NGINX. It allows administrators to define one or more log files where error messages will be recorded, including critical errors, warnings, and informational messages about the operation of the server. The directive can take different log levels such as "debug", "info", "notice", "warn", "error", and "crit", which determine the severity of messages logged. The logs help in diagnosing problems and monitoring the performance and reliability of the server.

In its simplest form, the error_log directive takes a single argument specifying the file path for the log. If specified multiple times, NGINX will log messages to multiple files, each with potentially different log levels. This feature enables fine-grained control over logging; for example, you might send error messages to one log file and critical messages to another. By default, the log level is set to "error", which means only error messages and more severe messages will be logged unless configured otherwise.

Config Example

error_log /var/log/nginx/error.log warn;

Specifying an invalid file path will prevent logging and may cause issues during runtime.

Multiple error_log directives can lead to confusion if not properly managed, especially with differing log levels.

Ensure that the NGINX user has permissions to write to the log file location.

← Back to all directives