tj bollerman
12/30/2024, 6:42 PM~/my_package/tests/test_logging.py
import structlog
import logging
from prefect.logging import get_run_logger
from prefect import flow
test_logger = logging.getLogger(__name__)
def test():
structlog.get_logger().info("test from structlog", y=1)
test_logger.info("test from logging")
@flow()
def flow_func():
test()
if __name__ == "__main__":
flow_func.serve(
name="test",
)
I have set PREFECT_LOGGING_EXTRA_LOGGERS='my_package'
When running from a console this I get these logs
13:36:16.218 | INFO | prefect.flow_runs.runner - Runner 'test' submitting flow run '8b1f6602-d38b-43b0-964e-29c91a279859'
13:36:16.515 | INFO | prefect.flow_runs.runner - Opening process...
13:36:16.524 | INFO | prefect.flow_runs.runner - Completed submission of flow run '8b1f6602-d38b-43b0-964e-29c91a279859'
13:36:18.133 | INFO | Flow run 'pompous-tench' - Downloading flow code from storage at '.'
2024-12-30 13:36:18 [info ] test from structlog y=1
13:36:18.419 | INFO | Flow run 'pompous-tench' - Finished in state Completed()
13:36:18.734 | INFO | prefect.flow_runs.runner - Process for flow run 'pompous-tench' exited cleanly.
and from the local UI I see none of the logs.
Questions:
1. why is only the structlog showing on the console
2. why are none of the logs being propagated to the UI?
(prefect 2.20.10)Nate
12/30/2024, 6:54 PMlogging.yml
if you have many different loggers you want to use and be collected by prefecttj bollerman
12/30/2024, 6:57 PMNate
12/30/2024, 7:01 PMlogging.yaml
file is where things fit together
i suspect you'd want to add something like
# under the loggers section
my_package:
level: INFO
handlers: [console, api]
propagate: true
tj bollerman
12/30/2024, 7:10 PMNate
12/30/2024, 7:11 PMtj bollerman
12/30/2024, 9:17 PMPREFECT_LOGGING_EXTRA_LOGGERS
is a really nice functionality for outside libraries thotj bollerman
12/30/2024, 9:18 PM