Tips / Nginx

Nginx Error_log Configuration

Nginx serves millions of applications on a daily basis, and those millions of apps generate errors. Guess what? So do yours. Some of them are critical, while others are just notices. The important thing here is to get access to those errors to debug and have a clear view of what’s happening with your web applications.

In this article, you will explore the Nginx error_log configuration and how Nginx handles the types of errors that can be logged into the files.

Nginx error_log Syntax

The “error_log” directive is used to handle error logging information. It uses the following syntax:

error_log log_file log_level

For an example, add this block to your nginx configuration inside the http {} block.

error_log /etc/nginx/logs/error_log crit;

On this configuration, the path of the error_log file is defined, as well as the type (critical errors only) of errors that you want to log.

The path can be anything you need, for example:


Full example:

server {

access_log off;
log_not_found off;
error_log logs/cpaneltips-error_log crit;

Error_log Levels

You can specify many types/levels of errors to log into Nginx error_log.

emerg: used for emergency messages when your system may be unstable.
alert: alert messages of important issues.
crit: critical problems that need to be taken care of.
error: used to log errors; something went wrong while serving your page.
warn: warning messages; may indicate some kind of problem.
notice: will log notices; most of the time will be useless.
info: information messages; most of the time not important.
debug: full debug information; includes all the previous levels.

Understanding Error_log Priority

There are many types of error_log levels, and you need to understand the priority of each one. In the list, debug has top priority, as it includes the rest of the errors too. For example, if you specify crit as level, it will also capture errors labeled on emerg and alert levels. This means that higher levels have higher priority.

In other words, the high levels are debug, info, notice and warn; this will generate a big output in your error_log, and of course will contain much more information to debug your website errors. They can also contain a lot of useless information.

On the other side, you will find emerg, alert, crit and error. These are the most common values recommended for normal debugging, because they capture most of the important problems that Nginx is facing while serving your web apps.

Remote error_log configuration with SysLog

Syslog is the log collector for unix/linux systems. It allows services to log the errors and access in one single location. This can be applied to Nginx too. Enable Nginx to generate error_logs using Syslog from a remote server just specifying ‘syslog’ and the IP address.

Example of remote syslog server:

error_log syslog:server= debug;

How to disable error_log on Nginx

This is a tricky configuration, since many people think that setting error_log off will disable the logging. However, it becomes the opposite and logs every error into a file called ‘off.’ If you want to fully disable Nginx error_log, then throw the output to /dev/null.

error_log /dev/null crit;


The error_log is one of those directives that sometimes we don’t pay too much attention to. Yet, as you’ve seen today, if you have it well configured, it can help you to save hours of time and money while investigating errors in your web applications. Problems can be fully diagnosed and resolved with minimal time and effort.

If you want to read more, check out the official docs: Nginx error_log

Popular search terms:

  • nginx log
  • nginx log level
  • ngix worn crit
  • nginx error log directive

Esteban Borges

Linux Geek, Webperf Addict, Nginx Fan. CTO @Infranetworking

  • If you use logging to a file, don’t forget to enable open_log_file_cache.

    open_log_file_cache max=1000 inactive=20s min_uses=2 valid=1m;

    Else, your server load will rise quickly with heavy traffic because of disk IO.