https://prefect.io logo
Title
j

jack

05/24/2023, 5:57 PM
Is there a way to get timestamps on the prefect agent logs? We are running the agent on a windows server using nssm, and the STDERR appears to have no timestamps.
z

Zanie

05/24/2023, 6:09 PM
Hm there are timestamps in all of our default logging configs. Did you change the log format?
j

jack

05/24/2023, 6:25 PM
We do get timestamps on the logs that are shipped to prefect. But the STDERR from the prefect agent itself appears to have no timestamps. We have this environment variable set to affect the logs that go to prefect:
SET "PREFECT_LOGGING_FORMATTERS_STANDARD_TASK_RUN_FMT=%(asctime)s.%(msecs)03d | %(levelname)-7s | %(task_name)s | %(message)s"
Here are the last three lines of STDERR captured in the logfile:
<frozen runpy>:128: RuntimeWarning: 'prefect.engine' found in sys.modules after import of package 'prefect', but prior to execution of 'prefect.engine'; this may result in unpredictable behaviour
<frozen runpy>:128: RuntimeWarning: 'prefect.engine' found in sys.modules after import of package 'prefect', but prior to execution of 'prefect.engine'; this may result in unpredictable behaviour
<frozen runpy>:128: RuntimeWarning: 'prefect.engine' found in sys.modules after import of package 'prefect', but prior to execution of 'prefect.engine'; this may result in unpredictable behaviour
z

Zanie

05/24/2023, 6:38 PM
Those aren't logs, those are just warnings Python is emitting to stderr.
j

jack

05/24/2023, 9:32 PM
Okay, two questions: 1. Is it a heavy lift to get timestamps on those warnings emitted to stderr? 2. Is the warning important, or does everybody get this warning?
z

Zanie

05/24/2023, 9:44 PM
1. Yes that's not controlled by us and bypasses logging. We'd need to hook into all stderr which would be weird. 2. Not important. We want to fix it, but it has no effect so it's a low priority