Skip to content

Python3.13 logging level not working #131789

Closed as not planned
Closed as not planned

Description

@trivialkettle

Bug description:

Hi,
i noticed a regression in python 3.13.2 that the log level has no effect.
I tested the example from https://docs.python.org/3.13/library/logging.html

import logging
logger = logging.getLogger(__name__)

def main():
    logging.basicConfig(filename='myapp.log', level=logging.INFO)
    logger.info('Started')
    logger.info('Finished')

if __name__ == '__main__':
    main()
python3.13 example.py 

but nothing is printed.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

Activity

  1. graingert commented on Mar 27, 2025

    @graingert
    Contributor

    you configured logging.basicConfig(filename='myapp.log', level=logging.INFO) this means nothing will be printed, instead logs will be written to myapp.log

  2. ericvsmith commented on Mar 27, 2025

    @ericvsmith
    Member

    As @graingert mentions, the output does show up in the file myapp.log.

    If this is a regression, then in what version of python did it produce output?

    I don't think there's a bug here, but if this did behave differently in a previous version of python that would be interesting.

  3. trivialkettle commented on Mar 27, 2025

    @trivialkettle
    Author

    Ah sorry, you are right, I missed this.

    I had some strange issues, that I could not set the logger level, my code works on python 3.10 but not on 3.13.

    basically I do

        logging.basicConfig(stream=sys.stderr, level=args.log, format="%(asctime)s:" + logging.BASIC_FORMAT)
    ...
        class Foo:
            self._logger = logging.getLogger(self.__module__)
    
        def foo():
            self._logger.debug("foo")

    I try to reproduce this, maybe it was a glitch or something.

    Edit: I close it for now until I can reproduce this.

  4. added and removed
    type-bugAn unexpected behavior, bug, or error
    on Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions