Skip to content

backupCount is not respected in TimedRotatingFileHandler when namer is specified #88916

Description

@alexandersmirnoff
BPO 44753
Nosy @vsajip, @miss-islington
PRs
  • bpo-44753: Don't use logfile extension when determining old files to … #27475
  • [3.9] bpo-44753: Don't use logfile extension when determining old files to be deleted (GH-27475) #27486
  • [3.10] bpo-44753: Don't use logfile extension when determining old files to be deleted (GH-27475) #27487
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-07-30.16:22:12.730>
    created_at = <Date 2021-07-27.22:37:54.989>
    labels = ['library', '3.9', '3.10']
    title = 'backupCount is not respected in TimedRotatingFileHandler when namer is specified'
    updated_at = <Date 2021-07-30.16:22:12.729>
    user = 'https://bugs.python.org/alexandersmirnoff'

    bugs.python.org fields:

    activity = <Date 2021-07-30.16:22:12.729>
    actor = 'vinay.sajip'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-07-30.16:22:12.730>
    closer = 'vinay.sajip'
    components = ['Library (Lib)']
    creation = <Date 2021-07-27.22:37:54.989>
    creator = 'alexander.smirnoff'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44753
    keywords = ['patch']
    message_count = 6.0
    messages = ['398326', '398537', '398538', '398568', '398569', '398570']
    nosy_count = 3.0
    nosy_names = ['vinay.sajip', 'miss-islington', 'alexander.smirnoff']
    pr_nums = ['27475', '27486', '27487']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue44753'
    versions = ['Python 3.9', 'Python 3.10']

    Activity

    1. alexandersmirnoff commented on Jul 27, 2021

      alexandersmirnoffmannequin
      MannequinAuthor

      after adding namer callable (like it is described in https://bugs.python.org/issue43344) to log handler configuration, it stopped removing old files

      log_filename = os.path.join(log_dir, "application.log")
      log_handler = logging.handlers.TimedRotatingFileHandler(log_filename, when='MIDNIGHT', interval=1, backupCount=7)

      // after adding this line, old files are not deleted
      log_handler.namer = lambda name: name.replace(".log", "") + ".log"

    2. vsajip commented on Jul 30, 2021

      @vsajip
      Member

      New changeset 6ff8903 by Vinay Sajip in branch 'main':
      bpo-44753: Don't use logfile extension when determining old files to be deleted (GH-27475)
      6ff8903

    3. vsajip commented on Jul 30, 2021

      @vsajip
      Member

      Should be fixed in main, leaving open until backports are done.

    4. vsajip commented on Jul 30, 2021

      @vsajip
      Member

      New changeset 882e476 by Miss Islington (bot) in branch '3.9':
      bpo-44753: Don't use logfile extension when determining old files to be deleted (GH-27475) (GH-27486)
      882e476

    5. vsajip commented on Jul 30, 2021

      @vsajip
      Member

      New changeset 6e6dc25 by Miss Islington (bot) in branch '3.10':
      bpo-44753: Don't use logfile extension when determining old files to be deleted (GH-27475) (GH-27487)
      6e6dc25

    6. vsajip commented on Jul 30, 2021

      @vsajip
      Member

      Thanks for the bug report.

    7. transferred this issue fromon Apr 10, 2022
    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

      3.10 (EOL)end of life3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directory

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions