I'm using Django with FastCGI + nginx. Where are the logs (errors) stored in this case?
10 Answers
Errors are stored in the nginx log file. You can specify it in the root of the nginx configuration file:
error_log  /var/log/nginx/nginx_error.log  warn;
On Mac OS X with Homebrew, the log file was found by default at the following location:
/usr/local/var/log/nginx
 
    
    - 30,738
- 21
- 105
- 131
 
    
    - 5,818
- 1
- 16
- 2
- 
                    13That's maybe version dependent but my log is inside: `/opt/nginx/logs/error.log` – jmarceli Apr 29 '15 at 23:26
- 
                    56on Mac OS X with homebrew: /usr/local/var/log/nginx. see lfender's [answer](http://stackoverflow.com/a/27402568/576767) – Félix Adriyel Gagnon-Grenier Nov 17 '15 at 17:34
- 
                    15On ubuntu I have it in `/var/log/nginx/error.log`. It is best to check the `nginx.conf` file and find the `error_log` setting. – MarthyM Dec 15 '16 at 13:06
- 
                    2Found mine at /opt/homebrew/var/log/nginx/error.log lol. Currently on macOS 13 (Ventura). Also seems you could run `nginx -h` to view the default log output directory. – takanuva15 Apr 11 '23 at 19:16
I was looking for a different solution.
Error logs, by default, before any configuration is set, on my system (x86 Arch Linux), was found in:
/var/log/nginx/error.log
 
    
    - 30,738
- 21
- 105
- 131
 
    
    - 54,723
- 49
- 178
- 224
- 
                    1Apparently this is configureable only at compile time with the `--error-log-path` compile option http://trac.nginx.org/nginx/ticket/147 – Michael Berkowski Oct 21 '14 at 14:57
- 
                    
You can use lsof (list of open files) in most cases to find open log files without knowing the configuration.
Example:
Find the PID of httpd (the same concept applies for nginx and other programs):
$ ps aux | grep httpd
...
root     17970  0.0  0.3 495964 64388 ?        Ssl  Oct29   3:45 /usr/sbin/httpd
...
Then search for open log files using lsof with the PID:
$ lsof -p 17970 | grep log
httpd   17970 root    2w   REG             253,15     2278      6723 /var/log/httpd/error_log
httpd   17970 root   12w   REG             253,15        0      1387 /var/log/httpd/access_log
If lsof prints nothing, even though you expected the log files to be found, issue the same command using sudo.
You can read a little more here.
 
    
    - 30,738
- 21
- 105
- 131
- 
                    6it's a nice trick to remember.. no guessing any more where the log files could be – Yo Ludke Jan 13 '15 at 08:47
- 
                    23
- 
                    2+1 For an answer on how to look. I was looking for logs from a different installation of nginx and it wasn't in the top answer. – Robert Dundon Dec 09 '16 at 15:23
- 
                    1you can poke at similar data on linux in the `/proc` filesystem. `/proc/${pid}/fd` has symlinks to the open files, pipes, devices, etc – Avindra Goolcharan Aug 13 '19 at 18:49
- 
                    while using [$ ps aux | grep httpd] I got =auto httpd (in red). do you know what it means please? – Debbie Jul 28 '22 at 20:49
Run this command, to check error logs:
tail -f /var/log/nginx/error.log
 
    
    - 4,979
- 12
- 37
- 45
 
    
    - 10,250
- 4
- 49
- 53
My ngninx logs are located here:
/usr/local/var/log/nginx/*
You can also check your nginx.conf to see if you have any directives dumping to custom log. 
run nginx -t to locate your nginx.conf. 
# in ngingx.conf
error_log  /usr/local/var/log/nginx/error.log;
error_log  /usr/local/var/log/nginx/error.log  notice;
error_log  /usr/local/var/log/nginx/error.log  info;
Nginx is usually set up in /usr/local or /etc/. The server could be configured to dump logs to /var/log as well. 
If you have an alternate location for your nginx install and all else fails, you could use the find command to locate your file of choice.
find /usr/ -path "*/nginx/*" -type f -name '*.log', where /usr/ is the folder you wish to start searching from.
 
    
    - 33,652
- 11
- 120
- 99
Logs location on Linux servers:
Apache – /var/log/httpd/
IIS – C:\inetpub\wwwroot\
Node.js – /var/log/nodejs/
nginx – /var/log/nginx/
Passenger – /var/app/support/logs/
Puma – /var/log/puma/
Python – /opt/python/log/
Tomcat – /var/log/tomcat8
 
    
    - 30,738
- 21
- 105
- 131
 
    
    - 992
- 1
- 12
- 15
Type this command in the terminal:
sudo cat /var/log/nginx/error.log
 
    
    - 30,738
- 21
- 105
- 131
 
    
    - 497
- 5
- 4
- 
                    2That is not an answer and should be a comment instead. Once you have sufficient reputation you will be able to comment. – mrun Jan 04 '18 at 06:25
For Mac OS users, you can type nginx -help in your terminal.
nginx version: nginx/1.21.0
Usage: nginx [-?hvVtTq] [-s signal] [-p prefix]
             [-e filename] [-c filename] [-g directives]
Options:
  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -T            : test configuration, dump it and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /opt/homebrew/Cellar/nginx/1.21.0/)
  -e filename   : set error log file (default: /opt/homebrew/var/log/nginx/error.log)
  -c filename   : set configuration file (default: /opt/homebrew/etc/nginx/nginx.conf)
  -g directives : set global directives out of configuration file
Then, you could find some default path for configuration and log files, in this case:
/opt/homebrew/log/nginx/error.log
 
    
    - 2,958
- 2
- 13
- 32
It is a good practice to set where the access log should be in nginx configuring file . Using acces_log /path/ Like this.
keyval $remote_addr:$http_user_agent $seen zone=clients;
server { listen 443 ssl;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers   HIGH:!aNULL:!MD5;
if ($seen = "") {
    set $seen  1;
    set $logme 1;
}
access_log  /tmp/sslparams.log sslparams if=$logme;
error_log  /pathtolog/error.log;
# ...
}
 
    
    - 179
- 9
 
     
    