dum3ng / study-issues

0 stars 0 forks source link

logger.setLevel does not work #35

Closed dum3ng closed 4 years ago

dum3ng commented 4 years ago

When using the logging library, directly use the logger.setLevel does not work:

import logging

logger = logging.getLogger(__name__)

logger.setLevel(logging.DEBUG)

logger.debug('debug info')

The debug message will not be logged to stdout.

solution

Call logging.basicConfig first:

logging.basicConfig(level=logging.INFO)  # set any level

logger.setLevel(logging.DEBUG)