question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Django logs shell exceptions (with Django > 2.0)

See original GitHub issue

I’m not completely sure whether this is a change in Django or in Raven.

I’ve started seeing typos in the manage.py shell log to Sentry since I upgraded to django 2.0, raven 6.4.0 and Python 3.6. I’ve come up with a hacky work around, but it did clarify that there’s no easy way to disable the sentry client that I could find documented.

Is there any change at this end which might have caused this?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:14
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jacobwegnercommented, Jul 20, 2018

I think I’ve tracked this down to the (good!) change that happened between 6.0.0 and 6.1.0:

fix registration of hooks for Django

PR: https://github.com/getsentry/raven-python/pull/966

Original issue: https://github.com/getsentry/raven-python/issues/884

Since install_sys_hook is working correctly, exceptions raised within a manage.py|django-admin.py session are handled by Sentry.

Here is a basic workaround I’ve settled on (YMMV):

# in settings.py
import sys
SHELL = "shell" in sys.argv
...
RAVEN_CONFIG = {
    "ignore_exceptions": ("*") if SHELL else ()
}

In should_capture, the wildcard"*" will match any exception.

Other manage.py commands that don’t have a “shell” argument will continue to send exceptions to Sentry.

1reaction
rowanseymourcommented, Aug 14, 2018

@jacobwegner it still works (thanks!), but I think in your solution you meant ("*",) instead of ("*")?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Logging - Django documentation
Overview. Django uses and extends Python's builtin logging module to perform system logging. This module is discussed in detail in Python's own documentation; ......
Read more >
Logging - Django documentation
A quick logging primer. Django uses Python's builtin logging module to perform system logging. The usage of this module is discussed in detail...
Read more >
Django 2.0 release notes
Django 2.0 supports Python 3.4, 3.5, 3.6, and 3.7. We highly recommend and only officially support the latest release of each series.
Read more >
Testing tools - Django documentation
If you point the test client at a view that raises an exception and Client.raise_request_exception is True , that exception will be visible...
Read more >
How to *always* log exceptions and stacktraces in django with ...
Though there is no default config where all exceptions are being recorded in a log file, there are couple of options for you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found