<@ULVA73B9P> When defining a custom file handler i...
# ask-marvin
m
@Marvin When defining a custom file handler in
logging.yaml
file, how can I set the name of the log file to be the flow run's name? So when specifying the
filename
instead of hardcoding it like
C:/PrefectLogs/test.log
, I want to dynamically set it like
C:/PrefectLogs/test_{flow_run_name}.log
?
m
Based on the information I found, it seems that you can override the output filename for the logs by setting an environment variable before starting each agent. Here is an example:
Copy code
bash
$ PREFECT_LOGGING_HANDLERS_FILE_FILENAME=/var/log/prefect-agent1.log prefect agent start -q default
However, I couldn't find a direct way to set the log filename dynamically based on the flow run's name in the
logging.yaml
file. The variables available for interpolation in log messages vary by logger and it seems that the filename might not be one of them. You might need to implement a custom solution, such as a script that starts the flow and sets the environment variable based on the flow run's name. Please note that this is just a suggestion and might require further investigation.