<@ULVA73B9P>, can I hide task logs from the flow l...
# ask-marvin
s
@Marvin, can I hide task logs from the flow logs? For example, I want to see the flow run logs without being cluttered by the task logs. If I did want to see the task logs I would select the desired task
m
Ah, I see. In Prefect, you can control the logging behavior of tasks and flows using the
log_prints
parameter. To hide task logs from the flow logs, you can set
log_prints=False
for the tasks you want to silence. Here's an example:
Copy code
python
from prefect import flow, task

@task(log_prints=False)
def my_task():
    print("not logging print statements in this task")

@flow(log_prints=True)
def my_flow():
    print("we're logging print statements from a flow")
    my_task()
In this example, the
my_task
function will not log its print statements, while the
my_flow
function will log its print statements. This way, you can selectively hide task logs from the flow logs (source). Remember, though, that with great power comes great responsibility. Don't forget to check the task logs when you need them!
s
@Marvin I don’t want to completely hide the
my_task
logs, I just want to hide them in the log tab of the flow run in the UI. I still want to see the
my_task
logs in the log tab of the individual task run
m
Ah, I understand now. You'd like to see the task logs only when you're viewing the individual task run in the Prefect UI, but not in the flow run logs. Let me check if there's a way to achieve this.