I'm not able to see the logs for my flows which I ...
# ask-community
v
I'm not able to see the logs for my flows which I used to be able to previous. Yes, my log_stdout is set to True in task settings. Any reason why this is happening?
Here's a screenshot
k
Hey Varun, is this happening for all your flows or just this one flow? Did you change the flow and re-register before this happened?
How long ago were these logs written?
v
Hi @Kevin Kho, this is happening for all the flows. Yes, I had to update my code and re-register the flow. We've been running these flows on and off since the past 2 months. So the logs have been written since then
c
Hi @Varun Joshi — your tenant was flagged and blocked from sending logs for producing spam-like behavior in our API; I believe your flows were sending something on the order of 10,000 logs per minute
v
Hi @Chris White, I think you're right. We have 166 flows running at a 1 min frequency and all of them were generating logs.
Hi @Chris White, please let me know how to resolve this. We need access to our logs
c
Hi Varun - you’ll need to find a way to reduce the number of logs you are sending; when I originally checked it appeared you were sending single word logs, so maybe try to consolidate those?
v
Hey @Chris White, I actually print my logs in one line. However, the log get's printed on each line for some reason. For example: The following statement will get printed as,
Copy code
print('data recieved|logtime:',datetime.datetime.now(), '|Source ID:',source_database_id)
data received logtime 04-19-2021 114900 Source ID ABC
Wish I could've replied earlier but either I didn't get a notification of your message or I missed it 😅
k
Are you using print? Maybe you can try using changing those prints to using the logger? https://docs.prefect.io/core/concepts/logging.html#logging-from-tasks
upvote 1
🙌 1
v
Okay, will do
I used prefect logger but the issue is persisting. I tried printing just a couple of statements but isn't working.
c
Hi Varun — at this moment your tenant is blocked from sending any logs; I can look into it on our end but we’d definitely want to be sure we won’t see the spam-like behavior again
v
Hi @Chris White, @Kevin Kho Thanks a lot for enabling our tenant again. I tried using logger.info and this error (in the screenshot). my logger.info statement is
Copy code
<http://logger.info|logger.info>(str(123)+ "error:" + exception_error)
c
Hi Varun, this will be hard to debug without knowing what
exception_error
is — usually this sort of error arises when you use templating strings like (notice the commas)
Copy code
<http://logger.info|logger.info>("hi %s", "chris", "unused string")
v
Copy code
exception_error
would be the
Copy code
except Exception as exception_error:
      <http://logger.info|logger.info>(str(123)+ "error:" + exception_error)
It'd be safe to presume that the exception_error will be a string, no?
c
No, exception_error will be an Exception type; for logging exceptions you should put whatever message you want and then pass exc_info=True to the logger call. So:
<http://logging.info|logging.info>(“Error raised.”, exc_info=True)
That way you don’t need to worry about the string formatting issues you’re running into + if will log the full trace back