-
-
Notifications
You must be signed in to change notification settings - Fork 608
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
[Bug?] Hydra turns on global logging to the info level #1262
Comments
@JackUrb, can you try to narrow it down? configure_log() is only doing this if it's called with a None log configuration, which should not be the case for normal operation. |
We're not using fairseq in Mephisto, so I'm not entirely sure where this comes in. Perhaps Mephisto isn't setting up Hydra use properly? Adding the |
Can you show me a minimal example of the problem without depending on anything except Hydra? |
(Sorry, I was thinking about parlai, not fairseq). |
Here's an even more minimal example:
And running it:
|
Thanks. what at the sh and shlex dependencies? how do I get them? |
This seems like expected behavior. https://github.com/facebookresearch/hydra/blob/master/hydra/conf/hydra/job_logging/default.yaml#L19 You can configure the logging by overriding the logging configuration. |
Found the sh package. Looking at the implications of not changing log level for the root logger. |
Regardless of the conclusion, you can do it on your side. see this for an example of how to configure the logging. |
Side note:
That's a claim I have yet to see proven with a minimal example. |
So they're related, the code that sets the logging level of the root logger to INFO is also applying a handler to the root logger, meaning that if I later add a handler for my specific needs, I get things logged to the stream twice when the logged event propagates up to the root: Line 52 in bc3567d
So if hydra is used in an application that applies any of its own loggers (rather than using the root logger) they get logs twice. Here's a minimal example for this behavior:
And the output:
The first log comes from my logger, the second comes from Hydra's |
First of all:
That code path only executes if the logging config provided to the function is None. I don't think it's actually running for you. Technically speaking, it's not Hydra that is adding the second handler, it's the app. Hydra is configuring the logging for the app. you can fully customize that configuration (including not do it at all, which will be easier in 1.1, #1130). You need to decide if you want to allow Hydra to configure the logging, or if you want to do it yourself. That sentence can also be interpreted as "Hydra should not be configuring the logging", but since you have full control over what config Hydra is using to configure the logging, I think it's worth supporting it (No logging configuration will be perfect for all use cases). |
#1263 is changing the default log level to WARN. |
I abandoned #1263. Applications that does like the default behavior has two options:
Happy to help you with your specific use case (Jump to the Hydra chat). |
I think 1.1 will end up being the resolution. I'm fine just disabling the logging (as we already have a fairly extensive logging setup for Mephisto) so the real concern was the simplicity by which we could disable it for all Mephisto-related |
Gotcha, yeah - recursive defaults should cover it. I do suggest that you see if you can migrate your logging configuration to Hydra instead of doing it yourself in code. |
To clarify to anyone reading this later:
You can see the current logging configuration with: $ python my_app.py --cfg hydra -p hydra.job_logging
# @package hydra.job_logging
version: 1
formatters:
simple:
format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s'
handlers:
console:
class: logging.StreamHandler
formatter: simple
stream: ext://sys.stdout
file:
class: logging.FileHandler
formatter: simple
filename: ${hydra.job.name}.log
root:
level: INFO
handlers:
- console
- file
disable_existing_loggers: false You can see that the root level is INFO above.
|
Description
Extending on #1012, Hydra doesn't simply duplicate logs, but it also turns on logging of all loggers globally to the INFO level:
hydra/hydra/core/utils.py
Line 46 in bc3567d
This leads me to get all kinds of spam from other used packages...
Is this actually a desired behavior? If so downstream packages will have to add:
to all defaults lists to circumvent Hydra updating the global logger, but I'm not sure if I'm losing important logging info by doing this. Am I missing something?
Checklist
To reproduce
Clone Mephisto.
Run an example script, like
python examples/parlai_chat_task_demo/parlai_test_script.py
See logs like the following:
** Stack trace/error message **
Expected Behavior
I wouldn't expect using Hydra would cause me to see info logs of other modules like
sh
.System information
The text was updated successfully, but these errors were encountered: