0

I'm trying to implement something like Django's yellow exception HTML page, where it has the stacktrace, local and global variables. And I want to log that info to a file on production where DEBUG=False.

I tried a custom middleware and only managed to log the stacktrace and the global variables, but most importantly I need to log the local variables of the views function or view class

McLovin
  • 51
  • 2
  • 6
  • 1
    You can extract these from the traceback: https://stackoverflow.com/a/36579700/67579 – Willem Van Onsem Nov 04 '20 at 17:23
  • 1
    Is there a reason why you do not use the Django handler? This is after all the handler that already implements this (and furthermore can often also locate errors in the template). The reason this is disabled with `DEBUG = False` is of course for security reasons, since you do not want to help hackers exploit vulnerabilities in the app. – Willem Van Onsem Nov 04 '20 at 17:25
  • 1
    See for example here https://github.com/django/django/blob/a492ccf0bc3da0b99c27b44e491ec3d6aabd5d3f/django/views/debug.py#L246 and here https://github.com/django/django/blob/master/django/views/templates/technical_500.html – Willem Van Onsem Nov 04 '20 at 17:38

0 Answers0