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

How to inherit hydra default logging parameters? #8

Open
SolomidHero opened this issue Apr 27, 2022 · 3 comments
Open

How to inherit hydra default logging parameters? #8

SolomidHero opened this issue Apr 27, 2022 · 3 comments

Comments

@SolomidHero
Copy link

SolomidHero commented Apr 27, 2022

Hi!
I love so much how this package deals with multiprocessing
I want to keep my current log settings like in facebookresearch/hydra since I adopted all logs to that format in my project.

I think about solution when setup_logging is used in main where hydra main config is available

Thank you.

@Dragon2fly
Copy link
Owner

Hi @SolomidHero,

As you may already know, copy a log_config.yaml, modify it, and then pass it to setup_logging will override logger-tt's default behavior. So just change the log format at line 8 or 11 to something like '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' as your need.

Have a good day.

@SolomidHero
Copy link
Author

SolomidHero commented Apr 29, 2022

Thak you very much!
I will try and answer back!

But can I set this format param using cfg.hydra.formatters.format in the code?
It seems that it is not enough. What params I am able to define from default hydra config?
hydra/conf/hydra/job_logging/default.yaml

formatters:
  simple:
    format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s'
handlers:
  console:
    class: logging.StreamHandler
    formatter: simple
    stream: ext://sys.stdout
  file:
    class: logging.FileHandler
    formatter: simple
    # absolute file path
    filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log
root:
  level: INFO
  handlers: [console, file]

disable_existing_loggers: false

@Dragon2fly
Copy link
Owner

Yes, you can.

Both libs use the standard logging module under the hood, so they share the same config file.
You can read more about the config file here

Except for the filename part in your config example, it may not be in a standard.

If you need more help, please be more specific about what have you tried, give an example of the real result, and your expectation.

Have a good day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants