My django app is working great with Debug=True. But now I'm in production and I want to email exceptions to me and print them to my logfile. I've been googling and searching the docs for the last 2 hours and what I really need is a snippet that shows how to do it in middleware/settings.py. I've never defined my own middleware and I'm just treading water. I've combined everything into my settings.py file to make it easier to explain, even if that may be bad design for now. Here's as far as I've gotten; which just times out on even valid requests:
---------------------------- settings.py--------------------------------------------------------------- partial def init_logging(): formatter = logging.Formatter("%(asctime)s - %(name)s - % (levelname)s - %(message)s") filelogger = logging.getLogger() filehandler = logging.FileHandler(LOGFILEPATH) filelogger.setLevel(logging.DEBUG) filehandler.setFormatter(formatter) filelogger.addHandler(filehandler) logInitDone=False if not logInitDone: logInitDone = True init_logging() logger = logging.getLogger("settings") #verified this logger does work. def process_exception(self, request, exception): logger.debug(str(request)) logger.debug(str(exception)) return None MIDDLEWARE_CLASSES = ( 'process_exception', #if I comment this out, system works, with it in response hangs even without error 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', # 'django.middleware.csrf.CsrfViewMiddleware', # 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', ) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.