2
2

I'm running SVN trunk at the moment, and observing that when an error occurs (e.g. when there's a template error, or a search fails due to misconfiguration) there are no errors in the logs (either the django.osqa.log or the Apache error_log.

I've modified settings_local.py and bumped the log level to logging.DEBUG, but I'm not seeing any more information.

I know that logging is working, because I was seeing errors generated by the error page about missing CONTACT_URL settings (which is now resolved).

Is there any logging when there are errors, and if they're meant to be in django.osqa.log how do I go about finding why they're not being logged?

asked 15 Jul '10, 22:26

Tim%20Whittington's gravatar image

Tim Whittington
1863811
accept rate: 25%


I've tried to get errors logged in the Apache logs with LogLevel info, but haven't had any success. Things like broken templates etc. just aren't logged. I only get errors in that log for core modules (i.e. stuff like the openid etc. - nothing from the forum app).

Installing a top level error handler in the Django middleware stack seems to work well though - all errors are logged into django.osqa.log.

Perhaps someone with more Python/Django experience could comment on whether this is the best way to go.

What I did was the following...

In settings.py:

MIDDLEWARE_CLASSES = [
'forum.middleware.log_errors.LogErrorsMiddleware',
#'django.middleware.gzip.GZipMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
...

In forum/middleware/log_errors.py (new file):

# Write all unhandled exceptions to log
import logging
class LogErrorsMiddleware(object):
    def process_exception(self, request, exception):
        logging.error("Unhandled exception:", exc_info=True)
        return None
link

answered 19 Jul '10, 04:08

Tim%20Whittington's gravatar image

Tim Whittington
1863811
accept rate: 25%

Well that's a perfectly valid way to handle them. But I think that misses lot of the request life cycle (stuff executed by django itself). Anyway, you can try setting this http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#admins> to get email notifications when stuff happens.

(19 Jul '10, 06:07) Hernani Cerq... ♦♦

I've discovered the Django DEBUG=True option, which gives me really big error pages with lots of information. It's probably sufficient if I can't find anything else.

link

answered 15 Jul '10, 22:36

Tim%20Whittington's gravatar image

Tim Whittington
1863811
accept rate: 25%

I'm seeing the same with Debug True and the level set to debug. In settings_local.py if I explicitly log something then it appears in the log, but nothing else ever does.

link

answered 16 Jul '10, 16:27

Andrew's gravatar image

Andrew
1
accept rate: 0%

The only errors logged in django.osqa.log are the error that can be predicted, I mean, the ones that we can circumvent or at least show some nicer error message. The ones that we do not have catch blocks for them are suposed to be logged in the apache error log. If you don't see them try checking the the log level parameter vhost file.

link

answered 16 Jul '10, 20:06

Hernani%20Cerqueira's gravatar image

Hernani Cerq... ♦♦
16.8k65975
accept rate: 52%

Thanks for clarifying!

(16 Jul '10, 20:31) Andrew

hmm is it possible to get them also in the django.osqa.log, not just apache log? I always assumed the intention of that file was to log every important event.

(19 Jul '10, 02:00) Joseph

Well, if those errors are not expected it's difficult to trap them unless we become paranoid and wrap everything in try/except clauses. And even that way is not always possible, because there's a fair amount of code that is out of our control, django stuff. Those errors are the exception and should not occur. if you're looking for a way to be warned of all the 500 that occur try setting this http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#admins.

(19 Jul '10, 06:01) Hernani Cerq... ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×56
×8

Asked: 15 Jul '10, 22:26

Seen: 553 times

Last updated: 19 Jul '10, 06:07

powered by OSQA