Skip to content
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

Implemented disabling logging configuration & added config file #1130

Merged
merged 10 commits into from
Nov 12, 2020
5 changes: 5 additions & 0 deletions hydra/conf/hydra/hydra_logging/none.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @package _group_

version: 1
root: null
disable_existing_loggers: false
5 changes: 5 additions & 0 deletions hydra/conf/hydra/job_logging/none.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @package _group_

version: 1
root: null
disable_existing_loggers: false
3 changes: 2 additions & 1 deletion hydra/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def configure_log(
conf: Dict[str, Any] = OmegaConf.to_container( # type: ignore
log_config, resolve=True
)
logging.config.dictConfig(conf)
if conf["root"] is not None:
logging.config.dictConfig(conf)
else:
# default logging to stdout
root = logging.getLogger()
Expand Down
1 change: 1 addition & 0 deletions news/1130.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
It is now possible to disable Hydra's logging configuration
11 changes: 11 additions & 0 deletions tests/test_examples/test_configure_hydra.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ def test_logging(tmpdir: Path) -> None:
assert result == "[INFO] - Info level message"


def test_disabling_logging(tmpdir: Path) -> None:
cmd = [
"examples/configure_hydra/logging/my_app.py",
"hydra.run.dir=" + str(tmpdir),
"hydra/job_logging=none",
"hydra/hydra_logging=none",
]
result, _err = get_run_output(cmd)
assert result == ""


def test_workdir_config(monkeypatch: Any, tmpdir: Path) -> None:
script = str(Path("examples/configure_hydra/workdir/my_app.py").absolute())
monkeypatch.chdir(tmpdir)
Expand Down
5 changes: 3 additions & 2 deletions website/docs/tutorials/basic/running_your_app/4_logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ $ python my_app.py hydra.verbose=[__main__,hydra]
[2019-09-29 13:06:00,896][__main__][DEBUG] - Debug level message
```

You can disable the logging output using by setting `hydra/job_logging` to `disabled'
You can disable the logging output by setting `hydra/job_logging` to `disabled`
```commandline
$ python my_app.py hydra/job_logging=disabled
<NO OUTPUT>
```

Logging can be [customized](/configure_hydra/logging.md).
You can also set `hydra/job_logging=none` and `hydra/hydra_logging=none` if you do not want Hydra to configure the logging.

Logging can be [customized](/configure_hydra/logging.md).