Quick question regarding loggers, as I'm missing s...
# ask-community
j
Quick question regarding loggers, as I'm missing something that is probably obvious. How can I provide a configuration to a logger defined like this
Copy code
loggers_by_deployment_name = {
    "deploy": {"prod_logger": prod_logger},
    "local": {"console_logger": colored_console_logger},
}


env_config = dotenv_values(".env")

deployment_name = env_config["DAGSTER_DEPLOYMENT"]

active_logger = loggers_by_deployment_name[deployment_name]

defs = Definitions(assets=[some_asset], loggers=active_logger)
I need to configure my
prod_logger
. I have created a YAML config file, but I don't know how to provide it. I've read the documentation several time and I only saw the possibility to pass a config from the command line to a job, or from the dagit launchpad to a job.
o
you can "bake in" the config of a configurable class by calling
.configured
, i.e.
Copy code
loggers_by_deployment_name = {
    "deploy": {"prod_logger": prod_logger.configured(my_config_dictionary)},
    "local": {"console_logger": colored_console_logger},
}
this requires that you have your config loaded as a dictionary, which you can do with
Copy code
with open('my_config.yml', 'r') as file
    my_config_dictionary = yaml.safe_load(file)