Repository: cookiecutter/cookiecutter-django

Issue:
Improve logging to Sentry
## Description
In production, when something unexpected happens we should be notified. Since there is already Sentry integration in place, it would be good to be able to utilize the logging functionality of Sentry.

According to [Sentry documentation](https://docs.sentry.io/platforms/python/logging/ ) logging should be enabled by default. Maybe I am missing something but using the following code, we should be able to log it to Sentry.
```python
import logging
logging.error("I am an event")
```

I tried it, but I couldn't get it to work, probably because I am failing to understand how the loggers configuration in cookiecutter-django.


Discussion:
Does it work if you first get the logger for the current file? I mean something like this:

```python
import logging
logger = logging.getLogger(__name__)

logger.error("I am an event")
```

The way you suggest logging, the module uses the root logger:

> Logs a message with level ERROR on the root logger.

The Sentry SDK is initialised here and it's not clear how it changes the logging config:

https://github.com/pydanny/cookiecutter-django/blob/9a03cb9cfc685ea029ec57ca1c2517eef4f2fd49/%7B%7Bcookiecutter.project_slug%7D%7D/config/settings/production.py#L289-L300

I've heard that [`logging_tree`](https://pypi.org/project/logging_tree/) can be helpful for this.
I will try what you suggest and report back.

While we are on this subject, what workflow do you follow to log your errors?
@browniebroke 
I tried 
```python
import logging
logger = logging.getLogger(__name__)

logger.error("I am an event")
```
I can see the error message on the console, but not on Sentry.
The default logging setting for the Sentry logging module are redefined here:
https://github.com/pydanny/cookiecutter-django/blob/b5a306e679952c7bbe39a43e7ef2803f1cf834d9/%7B%7Bcookiecutter.project_slug%7D%7D/config/settings/production.py#L289-L292
It seems to me that the reason no logs were sent to Sentry is because `event_level` is set to `None`. I have set it to `logging.ERROR` and I am successfully receiving the logs on Sentry.

Since that was set to `None` it seems to be the desired behavior to *not* have the logs sent to Sentry. In my opinion, setting logs to Sentry is useful, since it doesn't require an extra setup to get notified for log errors. Do you think we should have this to be configurable through an environment variable? Something like:
```python
event_level=env.int('DJANGO_SENTRY_EVENT_LEVEL', None)
```

Good catch @demestav! 

I don't know why it was setup this way originally, but personally, I'd be in favour of changing this to change event level to errors, as per [the Sentry docs](https://docs.sentry.io/platforms/python/logging/), it seems like a better default. Adding another environment variable seems a bit too cumbersome to me.
I don't think it was the case before we changed the Sentry integration in https://github.com/pydanny/cookiecutter-django/pull/1820, so it looks like something we missed in the migration. 
Should I submit a PR?
Yes, please, more than welcome. 

Resolving patch:
diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py
--- a/{{cookiecutter.project_slug}}/config/settings/production.py
+++ b/{{cookiecutter.project_slug}}/config/settings/production.py
@@ -288,7 +288,7 @@ class MediaRootS3Boto3Storage(S3Boto3Storage):
 
 sentry_logging = LoggingIntegration(
     level=SENTRY_LOG_LEVEL,  # Capture info and above as breadcrumbs
-    event_level=None,  # Send no events from log messages
+    event_level=logging.ERROR,  # Send errors as events
 )
 
 {%- if cookiecutter.use_celery == 'y' %}


Test patch: