Search code examples
pythonpython-loggingfb-hydra

How can i log stdout and stderr outputs using fb-hydra?


I am trying to log stdout and stderr into a file.

I found custom.yaml file in the facebookresearch/hydra github.

# @package _group_
version: 1
formatters:
  simple:
    format: '[%(levelname)s] - %(message)s'
handlers:
  console:
    class: logging.StreamHandler
    formatter: simple
    stream: ext://sys.stdout
root:
  handlers: [console]

disable_existing_loggers: False

I figured that I am able to create a custom job_logging config file and log stderr by editing the file as below

stream: ext://sys.stderr

However, I want to log stderr and stdout at the same time.

I am having a hard time figuring it out.. Does anyone know how I can do it by changing the config file?


Solution

  • Hydra is forwarding your config (as a primitive dictionary) to logging.config.dictConfig. This is more of question about that API than about Hydra.

    Do you know how to do this via logging.config.dictConfig without Hydra?