Skip to content

logging.config.dictConfig can’t set SysLogHandler.append_nul #132539

Closed
@Hawk777

Description

@Hawk777

Bug report

Bug description:

Because logging.config.dictConfig can only pass constructor parameters, it’s impossible to set SysLogHandler.append_nul via dictConfig (for that matter, it’s also impossible to set ident, but that doesn’t really matter because you can just prepend the relevant text to every message in the formatter instead). Given that the SysLogHandler constructor only takes parameters of specific fixed names, no correct code can already have been passing a parameter to it named append_nul and been expecting something else to happen, so I don’t see how this would be a backwards compatibility issue.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Activity

added
pendingThe issue will be closed if no feedback is provided
and removed
type-bugAn unexpected behavior, bug, or error
on May 11, 2025
vsajip

vsajip commented on May 11, 2025

@vsajip
Member

Your assertion "can only pass constructor parameters" is not quite correct - you can pass things other than constructor parameters, as described in the documentation. The following script:

import logging
import logging.config

logging_config = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'syslog': {
            'class': 'logging.handlers.SysLogHandler',
            '.': {
                'append_nul': True,
                'ident': 'foo',
            }
        },
    },
    'root': {
        'handlers': ['syslog'],
        'level': 'DEBUG'
    }
}

logging.config.dictConfig(logging_config)
h = logging.getHandlerByName('syslog')
print(f'{h.append_nul=} {h.ident=}')

prints:

h.append_nul=True h.ident='foo'

So, I propose that this issue be closed as invalid.

Hawk777

Hawk777 commented on May 12, 2025

@Hawk777
ContributorAuthor

Yes it does; apologies for the noise. I just read the section of Dictionary Schema Details about handlers but missed that this mechanism exists.

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

    invalidpendingThe issue will be closed if no feedback is providedstdlibPython modules in the Lib dir

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      logging.config.dictConfig can’t set SysLogHandler.append_nul · Issue #132539 · python/cpython

      Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

      Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant