Export logging configuration as a dict

I’m curious if there’s a way to export* the logging configuration into a dictionary at runtime. This would be useful for someone using basicConfig who wants to start using dictConfig without losing their place. It could also be useful when debugging a program’s logging setup. I did a quick search of the logging & logging.config modules in a debugger, and a couple internet searches, and I didn’t find anything about this.

It may seem trivial to convert any basicConfig to a dict, but I think anything that makes it easier for people to start logging is a Good Thing. I’m hoping the configuration is already stored in a dictConfig-like form and could be exposed with a minimal amount of work.

*I know sometimes there are callables specified in the logging configuration, so I don’t mean to ask for a true export that can be round-tripped.

1 Like