Zach Schumacher
08/23/2021, 9:07 PMZach Schumacher
08/23/2021, 9:08 PM# set the django loggers to inherit from prefect config
_loggers = list(LOGGING["loggers"])
PREFECT_EXTRA_LOGGERS = str(_loggers)
os.environ["PREFECT__LOGGING__EXTRA_LOGGERS"] = PREFECT_EXTRA_LOGGERS
Kevin Kho
Zach Schumacher
08/23/2021, 9:10 PMZach Schumacher
08/23/2021, 9:10 PMZach Schumacher
08/23/2021, 9:10 PMlogger = logging.getLogger(__name__)
<http://logger.info|logger.info>("sup)
Zach Schumacher
08/23/2021, 9:10 PMKevin Kho
--show-flow-logs
on a local agent?Zach Schumacher
08/23/2021, 9:12 PMKevin Kho
dask-jobqueue
specifically where the logger works locally but doesn’t on Cloud. --show-flow-logs
will show it though. This happens when the extra logger is a different process than the one Prefect is running on and doesn’t get the CloudHandler attached to it. Do you think that could be the case here?Zach Schumacher
08/23/2021, 9:14 PMZach Schumacher
08/23/2021, 9:16 PMZach Schumacher
08/23/2021, 9:16 PMKevin Kho
Kevin Kho
prefect.context.config
correctly?Zach Schumacher
08/23/2021, 9:27 PMZach Schumacher
08/23/2021, 9:28 PMKevin Kho
Zach Schumacher
08/23/2021, 9:28 PMKevin Kho
Zach Schumacher
08/23/2021, 9:31 PMZach Schumacher
08/23/2021, 9:33 PMZach Schumacher
08/23/2021, 9:40 PMZach Schumacher
08/23/2021, 9:40 PMKevin Kho
Zach Schumacher
08/23/2021, 10:16 PMZach Schumacher
08/23/2021, 10:16 PMKevin Kho
Zach Schumacher
08/23/2021, 10:17 PMKevin Kho
Zach Schumacher
08/23/2021, 10:20 PMPREFECT_JOB_ENVIRONMENT = {
"ENVIRONMENT": ENVIRONMENT,
"DJANGO_SETTINGS_MODULE": "sbdeco.config.settings.production",
"PREFECT__LOGGING__EXTRA_LOGGERS": PREFECT_EXTRA_LOGGERS,
}
PREFECT_RUN_CONFIG = KubernetesRun(labels=[PREFECT_AGENT_LABEL], image=PREFECT_IMAGE, env=PREFECT_JOB_ENVIRONMENT)
Kevin Kho
Kevin Kho
Zach Schumacher
08/23/2021, 10:21 PMZach Schumacher
08/23/2021, 10:22 PMZach Schumacher
08/23/2021, 10:22 PMClaire Herdeman
08/23/2021, 10:30 PMimport logging
then create your logger as logger = logging.getLogger(__name__)
. However to have the logs work successfully in prefect, you need import prefect
, logger = prefect.context.get("logger")
. Note that you can't use from prefect import context
and that you invoke the logger WITHIN each task where you want logging, both per the docs.Claire Herdeman
08/23/2021, 10:30 PMZach Schumacher
08/23/2021, 10:32 PMClaire Herdeman
08/23/2021, 10:34 PM