简体   繁体   中英

How to see Django errors using NGINX and gunicorn

I have developed a Django app locally, and I am used to seeing the error messages on the webpage when things aren't correct with my programming. I have now moved this app over to digital ocean servers, using Ubuntu, NGINX, and gunicorn.

Now when I have a problem in my Django code someplace, I get served very basic error messages from NGINX (or gunicorn?) on the webpage. Is there a method to see the full error log (like when the django app is being served on the local test server)? Or anyway to see more advanced error logs? DEBUG is set to True.

In your settings.py file, add the following line. When DEBUG = False , as it should be when you're online, the following will email you whenever an error comes up. That way the full error log is never shown to other people.

ADMINS = [('your_name', 'you@your_email.com')]

But you will need your email server set up for this to work. To do that, you will have to add some records on your digital ocean server. Typically this is just an MX record, granting your server permission to send email from your_website.com . The instructions to do this depend on the email host you're using. If you're using something like fastmail, the directions are here.

CAUTION, IF YOU USE THIS: If your site has a lot of errors, and is being crawled by a lot of bots that get those errors, this can spam your email for every single error. So ideally you should always make sure your site is working on the development version first with no errors. If there are no errors there, add this line.... Then comment it out and restart gunicorn when you got the info you needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM