phillipsK
phillipsK

Reputation: 1516

Python logger debuging: No handlers could be found for logger "__main__"

I have a plivo conference call application. I am able to run the app fine locally, but when I run on heroku I am receiving the following error, which kills my app: 2015-02-12T05:36:08.173658+00:00 app[web.1]: No handlers could be found for logger "__main__" 2015-02-12T05:36:08.173695+00:00 app[web.1]: Pilvo error: CombinedMultiDict([ImmutableMultiDict([]), ImmutableMultiDict([('From', u'zzzphone'), ('Direction', u'inbound'), ('BillRate', u'0.00850'), ('CallerName', u'+yyyphone'), ('To', u'xxxphone'), ('CallStatus', u'ringing'), ('CallUUID', u'0aaf7442-b279-11e4-af9d-ff55a7d29b8a'), ('Event', u'StartApp')])]) ,

Here is all the code from my app which has the 'logger' module. I tried commenting the code out to identify the problem. The app is supposse to record a conference call, but when I dial the python app I do not even reach a main menu to enter a digit and THEN enter a conference instance, so the error must be inherent somewhere in this?

    logging.config.dictConfig({
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'recording': {
            'format': '[%(asctime)s]: %(message)s',
        },
        'verbose': {
            'format': '%(levelname)s::%(asctime)s::%(module)s -- %(message)s',
        }
    },
    'handlers': {
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'stream': sys.stdout,
            'formatter': 'verbose'
        },
        'recordings_file': {
            'level': 'INFO',
            'filename': 'recordings.log',
            'class': 'logging.FileHandler',
            'formatter': 'recording'
        },
        'logfile': {
            'level': 'DEBUG',
            'filename': 'debug.log',
            'class': 'logging.FileHandler',
            'formatter': 'verbose'
        }
    },

    'loggers': {
        'recordings': {
            'handlers': ['recordings_file'],
            'level': 'INFO',
            'propagate': True,
        },
        'root': {
            'handlers': ['logfile', 'console'],
            'level': 'INFO',
            'propagate': True
        },
    }
})
"""

logger = logging.getLogger(__name__)
recordings = logging.getLogger('recordings')

@app.route('/response/main_menu', methods=['GET', 'POST'])
def main_menu():
    logger.debug('New call')
    logger.debug('--')
    response = plivoxml.Response()

and here as well:

    app.route('/response/error_handler/', methods=['POST'])
def error_handler():
    logger.error('Pilvo error: %s , %s' % (request.values, request.data))
    print 'Pilvo error: %s , %s' % (request.values, request.data)

    response = plivoxml.Response()
    response.addRedirect(url_for('ivr', _external=True))

    return Response(str(response), mimetype='text/xml')

Upvotes: 0

Views: 1212

Answers (1)

John Mee
John Mee

Reputation: 52243

Are you using flask?

If so, try calling logger from the app:

app.logger.error('Pilvo error...')

Upvotes: 1

Related Questions