Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: asyncio logger is created before salt._logging and throws exceptions when jid is in log_fmt #68400

@barneysowood

Description

@barneysowood

What happened?

If you set log_fmt_console to contain %(jid)s and set log_level: debug, there will be exceptions generated on the console. This occurs for salt-master and salt-run.

$ salt-run -ldebug test.stdout_print

< lots of output...>

--- Logging error ---
Traceback (most recent call last):
  File "/opt/saltstack/salt/lib/python3.10/logging/__init__.py", line 440, in format
    return self._format(record)
  File "/opt/saltstack/salt/lib/python3.10/logging/__init__.py", line 436, in _format
    return self._fmt % values
KeyError: 'jid'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

< more traceback...>

  File "/opt/saltstack/salt/lib/python3.10/asyncio/selector_events.py", line 54, in __init__
    logger.debug('Using selector: %s', selector.__class__.__name__)
Message: 'Using selector: %s'
Arguments: ('EpollSelector',)

The issue is triggered by a call to log.debug() in the asyncio library. The logger for asyncio isn't using SaltLoggingClass because it is created before salt._logging is imported - there's an import asyncio right at the top of salt/__init__.py. The standard logging.Logger() class can't deal with %(jid)s.

This isn't an issue in 3006.x as the import of asyncio in salt/__init__.py doesn't exist there.

Type of salt install

Official deb

Major version

3007.x

What supported OS are you seeing the problem on? Can select multiple. (If bug appears on an unsupported OS, please open a GitHub Discussion instead)

ubuntu-24.04

salt --versions-report output

Salt Version:
          Salt: 3007.8

Python Version:
        Python: 3.10.18 (main, Sep  5 2025, 22:48:51) [GCC 11.2.0]

Dependency Versions:
          cffi: 1.16.0
      cherrypy: unknown
  cryptography: 42.0.5
      dateutil: 2.8.2
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.6
       libgit2: Not Installed
  looseversion: 1.3.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.7
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 24.0
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.19.1
        pygit2: Not Installed
  python-gnupg: 0.5.2
        PyYAML: 6.0.1
         PyZMQ: 25.1.2
        relenv: 0.20.6
         smmap: Not Installed
       timelib: 0.3.0
       Tornado: 6.4.2
           ZMQ: 4.3.4

Salt Package Information:
  Package Type: onedir

System Versions:
          dist: ubuntu 22.04.5 jammy
        locale: utf-8
       machine: x86_64
       release: 6.11.0-25-generic
        system: Linux
       version: Ubuntu 22.04.5 jammy

Metadata

Metadata

Assignees

Labels

bugbroken, incorrect, or confusing behavior

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions