{"record":{"id":"98132f6e50dd6201","repo":"aio-libs/aiohttp","slug":"gunicorn-s-style-options-in-form-of-name-s-are","errorCode":null,"errorMessage":"Gunicorn's style options in form of `%(name)s` are not supported for the log formatting. Please use aiohttp's format specification to configure access log formatting: http://docs.aiohttp.org/en/stable/logging.html#format-specification","messagePattern":"Gunicorn's style options in form of `(.+?)` are not supported for the log formatting\\. Please use aiohttp's format specification to configure access log formatting: http://docs\\.aiohttp\\.org/en/stable/logging\\.html#format-specification","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"aiohttp/worker.py","lineNumber":238,"sourceCode":"        See ssl.SSLSocket.__init__ for more details.\n        \"\"\"\n        if ssl is None:  # pragma: no cover\n            raise RuntimeError(\"SSL is not supported.\")\n\n        ctx = ssl.SSLContext(cfg.ssl_version)\n        ctx.load_cert_chain(cfg.certfile, cfg.keyfile)\n        ctx.verify_mode = cfg.cert_reqs\n        if cfg.ca_certs:\n            ctx.load_verify_locations(cfg.ca_certs)\n        if cfg.ciphers:\n            ctx.set_ciphers(cfg.ciphers)\n        return ctx\n\n    def _get_valid_log_format(self, source_format: str) -> str:\n        if source_format == self.DEFAULT_GUNICORN_LOG_FORMAT:\n            return self.DEFAULT_AIOHTTP_LOG_FORMAT\n        elif re.search(r\"%\\([^\\)]+\\)\", source_format):\n            raise ValueError(\n                \"Gunicorn's style options in form of `%(name)s` are not \"\n                \"supported for the log formatting. Please use aiohttp's \"\n                \"format specification to configure access log formatting: \"\n                \"http://docs.aiohttp.org/en/stable/logging.html\"\n                \"#format-specification\"\n            )\n        else:\n            return source_format\n\n\nclass GunicornUVLoopWebWorker(GunicornWebWorker):\n    def init_process(self) -> None:\n        import uvloop\n\n        asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())\n\n        super().init_process()\n","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/aio-libs/aiohttp/blob/d041d4d0fd48c3f0832084d33be16cf1c4835f85/aiohttp/worker.py#L220-L256","documentation":"Raised as a ValueError by GunicornWebWorker._get_valid_log_format() when the access-log format string contains a Gunicorn-style `%(name)s` placeholder. aiohttp's AccessLogger uses its own %-spec (e.g. %a %t %r %s %b), not Gunicorn's %(name)s dictionary form, so the worker rejects the incompatible format at startup. The exception bubbles out of _run() and aborts worker boot.","triggerScenarios":"Passing `--access-logformat '%(h)s %(l)s %(t)s %(r)s %(s)s %(b)s'` (a Gunicorn default-style string that is not exactly DEFAULT_GUNICORN_LOG_FORMAT) to the aiohttp gunicorn worker, or setting `access_log_format` in a gunicorn config file using %(name)s placeholders.","commonSituations":"Copying a gunicorn access_log_format from a Flask/Django deployment into an aiohttp config; a config file that worked under the sync gunicorn worker but is now pointed at GunicornWebWorker.","solutions":["Use aiohttp's format specification: e.g. `%a %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\"` (see http://docs.aiohttp.org/en/stable/logging.html#format-specification).","Remove the custom access_log_format to fall back to the aiohttp default.","If you only had Gunicorn's default format string, the worker auto-translates DEFAULT_GUNICORN_LOG_FORMAT to DEFAULT_AIOHTTP_LOG_FORMAT, so leaving it unset is safest."],"exampleFix":"// before\n# gunicorn.conf.py\naccess_log_format = '%(h)s %(l)s %(t)s \"%(r)s\" %(s)s %(b)s'\n\n// after\naccess_log_format = '%a %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\"'\n# or simply omit it to use the aiohttp default","handlingStrategy":"validation","validationCode":"import re\nassert not re.search(r'%\\([^)]+\\)', access_log_format), \\\n    'use aiohttp access log format, not gunicorn %(name)s'","typeGuard":"def is_aiohttp_log_format(fmt: str) -> bool:\n    import re\n    return not re.search(r'%\\([^)]+\\)s', fmt)","tryCatchPattern":"# raised at worker boot as ValueError; fix the config rather than catching.\n# Validate config before deploy:\ntry:\n    assert is_aiohttp_log_format(cfg.access_log_format)\nexcept AssertionError:\n    cfg.access_log_format = '%a %t \"%r\" %s %b'","preventionTips":["Use aiohttp's %-token format spec for access_log_format with the aiohttp worker.","Leave access_log_format unset to use the aiohttp default.","Do not copy gunicorn %(name)s format strings from sync-worker configs."],"tags":["gunicorn","logging","configuration","boot","deployment"],"backgroundTag":null,"analyzedSha":"d041d4d0fd48c3f0832084d33be16cf1c4835f85","analyzedAt":"2026-08-11T20:44:15.550Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}