Skip to content

Commit f4aba48

Browse files
committed
Move logging configuration to config file
1 parent 155ee4c commit f4aba48

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

source-code/hydra/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ or
5151
$ ./gen_rand.py --config-name=file_config.yaml
5252
```
5353

54+
Application logging is configured through Hydra in
55+
`conf/hydra/job_logging/custom.yaml`. The script still uses Python's
56+
`logging.getLogger(__name__)`, but formatting and log level are controlled
57+
from configuration. For example, to change the root log level:
58+
```bash
59+
$ ./gen_rand.py hydra.job_logging.root.level=DEBUG
60+
```
61+
5462
To perform multiple runs with different parameter values:
5563
```bash
5664
$ ./gen_rand.py -m distr=uniform,gauss

source-code/hydra/conf/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ n: 1
22
file: false
33
defaults:
44
- distr: gauss
5+
- override hydra/job_logging: custom
56
- _self_
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 1
2+
formatters:
3+
simple:
4+
format: '[%(asctime)s][%(name)s][%(levelname)s] %(message)s'
5+
handlers:
6+
console:
7+
class: logging.StreamHandler
8+
formatter: simple
9+
stream: ext://sys.stdout
10+
root:
11+
level: INFO
12+
handlers:
13+
- console
14+
disable_existing_loggers: false

0 commit comments

Comments
 (0)