Monitoring error logs is essential for maintaining a healthy web server and troubleshooting issues effectively. This guide provides a comprehensive overview of how to check error logs for Nginx, Gunicorn, and other related services.
Nginx Error Logs
Nginx logs errors to specific files which can be checked using the following commands:
Service | Log File | Command |
---|---|---|
Nginx | /var/log/nginx/error.log | sudo tail -f /var/log/nginx/error.log |
Gunicorn Error Logs
Gunicorn, being a Python WSGI HTTP server, logs its errors separately. Use the commands below to access these logs:
Service | Log File | Command |
---|---|---|
Gunicorn | /var/log/gunicorn/error.log | sudo tail -f /var/log/gunicorn/error.log |
Systemd Service Logs
If you are running Nginx and Gunicorn as systemd services, you can also check their logs using the journalctl
command:
Service | Command |
---|---|
Nginx | sudo journalctl -u nginx |
Gunicorn | sudo journalctl -u gunicorn |
Checking Logs for Other Services
Depending on your server configuration, you might need to check logs for additional services such as PostgreSQL, Redis, or Celery. Here’s how you can check those logs:
Service | Log File | Command |
---|---|---|
PostgreSQL | /var/log/postgresql/postgresql.log | sudo tail -f /var/log/postgresql/postgresql.log |
Redis | /var/log/redis/redis-server.log | sudo tail -f /var/log/redis/redis-server.log |
Celery | /var/log/celery/celery.log | sudo tail -f /var/log/celery/celery.log |
Summary Table of Commands
Service | Log File | Command |
---|---|---|
Nginx | /var/log/nginx/error.log | sudo tail -f /var/log/nginx/error.log |
Gunicorn | /var/log/gunicorn/error.log | sudo tail -f /var/log/gunicorn/error.log |
Nginx (systemd) | N/A | sudo journalctl -u nginx |
Gunicorn (systemd) | N/A | sudo journalctl -u gunicorn |
PostgreSQL | /var/log/postgresql/postgresql.log | sudo tail -f /var/log/postgresql/postgresql.log |
Redis | /var/log/redis/redis-server.log | sudo tail -f /var/log/redis/redis-server.log |
Celery | /var/log/celery/celery.log | sudo tail -f /var/log/celery/celery.log |
Conclusion
Regularly checking error logs is crucial for maintaining the stability and performance of your server. By using the commands outlined above, you can efficiently monitor and troubleshoot issues with Nginx, Gunicorn, and other related services.
Additional Resources
For more detailed information and additional configurations, you can refer to the following resources: