Logging.config providing JSON schema

One can configure Python logging from a config file. An example can be seen here: logging.config — Logging configuration — Python 3.12.0 documentation

It would be cool if logging.config library had a JSON schema that one can use. This way, one can validate a config file’s structure is actually valid.

Similarly, it would be cool if logging.config had a function to export the current config. This second idea is a duplicate of Export logging configuration as a dict.

1 Like

Python has no builtin jsonschema validator though. I agree with the premise, I like having schema files available to me, but having to immediately go 3rd party to use something in stdlib seems wrong.

This might be something which SchemaStore would be open to including.

I’m against the idea that this would be the responsibility of the language or stdlib maintainers. JSON Schema is a language unto itself – writing a good schema requires familiarity with that language.

If you’re interested, go ahead and open a PR. SchemaStore is a very welcoming project, in my experience, and has good/thorough contributing guidelines.

Although this does not validate at runtime, typeshed has basic typecheck support for dictConfig through the use of TypedDict, which is convenient when directly invoking the function with IDE auto-completions.