Skip to main content
Version: 1.1

Customizing logging

 Example

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 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
config.yaml
defaults:  - override hydra/job_logging: custom
hydra/job_logging/custom.yaml
version: 1formatters:  simple:    format: '[%(levelname)s] - %(message)s'handlers:  console:    class: logging.StreamHandler    formatter: simple    stream: ext://sys.stdoutroot:  handlers: [console]
disable_existing_loggers: false

This is what the default logging looks like:

$ python my_app.py hydra/job_logging=default[2020-08-24 13:43:26,761][__main__][INFO] - Info level message

And this is what the custom logging looks like:

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