Atlas functions seem to not display all of the logs when running in web UI

I’m trying to debug a trigger function with console logs in the web UI, but it seems like the output is getting cut off.

The following code should print out a few hundred log statements.

console.log('accounts', orgUtilityAccountsByHouse.length)
  console.log(Object.keys(orgUtilityAccountsByHouse).length)
  for (let x = 0; x < Object.keys(orgUtilityAccountsByHouse).length; x++){
    console.log(x, Object.keys(orgUtilityAccountsByHouse)[x])
  }

But instead I seemingly get a truncated version with only a few lines.
image

How exactly am I supposed to debug without being able to see logs?

Hi @Bowden_Kelly - Welcome to the community!

Thank for you providing those details :slight_smile:

But instead I seemingly get a truncated version with only a few lines.

Would you be able to clarify if you mean seeing the ~3-4 lines as shown in your screenshot?

I have done some testing on my end and it appears the console results output 100 lines of logs (based off my testing). However, in saying so, I did attempt to log 200 where only the most recent 100 had shown. I would just like to clarify if you meant that you could only see 3-4 log lines or if you had >100 log lines you wanted to see.

Regards,
Jason

3 Likes

Hi @Jason_Tran - you are correct. I get ~100 as well which isn’t super useful.

Thanks for clarifying @Bowden_Kelly

I’m still looking into this one but in the meantime for debugging purposes, would you be able to perhaps be output with longer lines (maybe with delimiters if you wish to parse the data)?

Regards,
Jason

2 Likes

Hmm something like storing all my logs on an increasingly large string and then print it all once at the end? That might work unless there is an exception. So I guess I could wrap the whole thing in a try / catch / finally a print the single line log that way. Then take that output, put it into another script that formats it? I’ll give it a shot I guess.

Though honestly, if this is the solution, I’ll probably just find another product. Is it unreasonable to want to see my function’s output? Feels like logging is table stakes.

Sorry your experience have not been as positive as you would like it to be. However, we’re keen to improve the usability of the product, and would be very interested if you’re able to provide a relevant feedback into the MongoDB feedback engine. All feedbacks are monitored by the product team, and would help with prioritizing future features of the product.