-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Existing loggers are overwritten by file config #985
Labels
Comments
janoskut
pushed a commit
to unumotors/behave
that referenced
this issue
Dec 27, 2021
Rationale: In behave, loggers are usually initialized before "before_all()" and "setup_logging()" are invoked. When using a file config, the default behavior of the logging module is to disable existing loggers (see warning in https://docs.python.org/3/howto/logging.html#configuring-logging). Changing the default behavior to not disabling the existing loggers matches behaves logger users better. By passing the **kwargs into "fileConfig()", we still allow all desired behaviors.
janoskut
pushed a commit
to unumotors/behave
that referenced
this issue
Oct 26, 2022
Rationale: In behave, loggers are usually initialized before "before_all()" and "setup_logging()" are invoked. When using a file config, the default behavior of the logging module is to disable existing loggers (see warning in https://docs.python.org/3/howto/logging.html#configuring-logging). Changing the default behavior to not disabling the existing loggers matches behaves logger users better. By passing the **kwargs into "fileConfig()", we still allow all desired behaviors.
janoskut
pushed a commit
to unumotors/behave
that referenced
this issue
Dec 21, 2022
Rationale: In behave, loggers are usually initialized before "before_all()" and "setup_logging()" are invoked. When using a file config, the default behavior of the logging module is to disable existing loggers (see warning in https://docs.python.org/3/howto/logging.html#configuring-logging). Changing the default behavior to not disabling the existing loggers matches behaves logger users better. By passing the **kwargs into "fileConfig()", we still allow all desired behaviors.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When we use
context.config.setup_logging(configfile=...)
, existing loggers are always overwritten by the new configuration. This is the default behavior by thelogging
module, and noted with a big warning in https://docs.python.org/3/howto/logging.html#configuring-logging:In
behave
, thebefore_all()
hook is normally invoked only after all other modules are imported, and hence after all file-global loggers are created. While it may be debatable, it is common practice to use file-global loggers such as:When using such modules in
behave
with file-config, those global loggers are overwritten, and all modules which use such loggers (e.g. step definitions, or from the system under test) won't provide logging.I suggest to at least pass all
**kwargs
tologging.config.fileConfig()
, to allow to overwrite this default behavior, or even more change the default behavior to "not disable existing loggers" (and still pass the kwargs to allow control of it).See the #986.
The text was updated successfully, but these errors were encountered: