I’m having some trouble connecting my Flask app to Sentry.
Sentry is catching exceptions and messages sent directly with sentry.captureMessage
, but requests logs or logs sent via app.logger
don’t seem to make it in.
import os
import logging
from flask import Flask, jsonify, abort, request, make_response, Response
from config import config
from raven.contrib.flask import Sentry
app = Flask(__name__)
environment = os.getenv('FLASK_CONFIG', 'default')
app.config.from_object(config)
sentry = Sentry(app, logging=True, level=logging.INFO)
@app.route('/example', methods=['GET'])
def example():
# This shows up in Sentry
sentry.captureMessage('this is a test')
# These do not show up in Sentry
app.logger.info('this is an info log')
app.logger.error('this is an error')
My gunicorn logs show when testing locally:
gunicorn --config config/gunicorn.py app:app
[2017-04-24 12:18:11 -0700] [80932] [INFO] Starting gunicorn 19.7.1
[2017-04-24 12:18:11 -0700] [80932] [INFO] Listening at: http://0.0.0.0:5000 (80932)
[2017-04-24 12:18:11 -0700] [80932] [INFO] Using worker: sync
[2017-04-24 12:18:11 -0700] [80947] [INFO] Booting worker with pid: 80947
[2017-04-24 12:18:11 -0700] [80948] [INFO] Booting worker with pid: 80948
[2017-04-24 12:18:11 -0700] [80954] [INFO] Booting worker with pid: 80954
[2017-04-24 12:18:11 -0700] [80955] [INFO] Booting worker with pid: 80955
--------------------------------------------------------------------------------
INFO in __init__ [/Users/me/sandbox/my_app/app/__init__.py:37]:
this is an info log
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
ERROR in __init__ [/Users/me/sandbox/my_app/app/__init__.py:38]:
this is an error
--------------------------------------------------------------------------------
Any ideas on why my app.logging
and/or request logs aren’t making it in?