Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to specify custom error log format on Nginx?

I can specify custom log format for access_log on Nginx, but it doesn't work for error_log.

Is there anyway to achieve this?

like image 533
tjeden Avatar asked Nov 22 '10 15:11

tjeden


People also ask

How do I change the log format in nginx?

The syntax for configuring a log format is: log_format format_name 'set_of_variables_to_define_format'; and the syntax for configuring access log is: access_log /path/to/log_file format_name; #simplest form OR access_log /path/to/log_file [format [buffer=size] [gzip[=level]] [flush=time] [if=condition]];

How do I change the error log in nginx?

Syntax of error_log in Nginx: For configuring the error_log, you have to add the path of the log file and set the log level. If you do not set the second parameter, then the error_log will take “error” as its default log level: error_log /var/log/nginx/error.

What log format does nginx use?

The default log format in nginx is called "combined".

What is error log in nginx?

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.


1 Answers

You can't specify your own format, but in nginx build-in several level's of error_log-ing.

Syntax: error_log file [ debug | info | notice | warn | error | crit ]

Default: ${prefix}/logs/error.log

Specifies the file where server (and fastcgi) errors are logged.

Default values for the error level:

  1. in the main section - error
  2. in the HTTP section - crit
  3. in the server section - crit

In my error_log, time always presented int begin of each error string in log.

like image 69
CyberDem0n Avatar answered Nov 11 '22 15:11

CyberDem0n