Skip to main content
Version: 0.11

Customizing logging

Hydra is configuring Python standard logging library with the dictConfig method. You can learn more about it here. There are two logging configurations, one for Hydra itself and one for the executed jobs.

This example demonstrates how to to customize the logging behavior of your Hydra app, by making the following changes to the default logging behavior:

  • Outputs only to stdout (no log file)
  • Output a simpler log line pattern

Project structure:

$ tree
β”œβ”€β”€ conf
β”‚Β Β  β”œβ”€β”€ config.yaml
β”‚Β Β  └── hydra
β”‚Β Β  └── job_logging
β”‚Β Β  └── custom.yaml
└── main.py

config.yaml defaults the application to the custom logging.

Config file: config.yaml

defaults:
- hydra/job_logging : custom

Config file: hydra/job_logging/custom.yaml

hydra:
job_logging:
formatters:
simple:
format: '[%(levelname)s] - %(message)s'
root:
handlers: [console]

This is what the the default logging looks like:

$ python main.py hydra/job_logging=default
[2019-09-26 18:58:05,477][__main__][INFO] - Info level message

And this is what the custom logging looks like:

$ python main.py
[INFO] - Info level message