Changing logging level only for my code?

egarrulo at egarrulo at
Mon Feb 8 06:29:39 EST 2016

I am using the "logging" module for my own package, but changing the level from "INFO" to "DEBUG" enables debugging statements from third-party libraries as well.  How can I avoid them?  Here is the code I am using:

    import logging

    logger = logging.getLogger(__name__)
    log_file = logging.FileHandler("activity.log", mode='w')
    log_file.setFormatter(logging.Formatter(fmt='%(levelname)s: %(message)s'))
    logging.basicConfig(level=logging.INFO) # or DEBUG

Thank you.

More information about the Python-list mailing list