xdhmoore
xdhmoore

Reputation: 9915

Turn on debug logging in python

I'm trying to turn on debug logging in python 3.5.2:

import logging
log = logging.getLogger('test')
log.setLevel(logging.DEBUG)

log.warn('warn')
log.debug('debug')

log.root.setLevel(logging.DEBUG)
log.debug('debug again')

However, this only prints warn. What am I missing?

Upvotes: 42

Views: 47184

Answers (1)

Harald Nordgren
Harald Nordgren

Reputation: 12439

This should accomplish what you want

logging.basicConfig(level=logging.DEBUG)

…followed by

log = logging.getLogger('test')
log.debug('debug') 

Upvotes: 59

Related Questions