How to silence a log after customLogger is deprecated?
I have some end to end tests that check error states in my application. This means there are requests made which I expect to return a 404 not found error.
I use Axios, and this ends up causing about 2,500 lines of error logs in my CI/CD output before all the e2e test results are shown. It's very annoying scrolling through all that everytime a test fails to see what went wrong.
I narrowed it down to a console.error coming from react-query. I was able to silence the error using
logger: { error: (error) => isExpected404(error) ? console.log('expected 404') : console.error(error)}
However that also starts this showing up:
"Passing a custom logger has been deprecated and will be removed in the next major version."
So how can I silence or suppress these thousands of lines of expected 404 error logs? I didn't see anything replacing the custom logger functionality.
Thanks for your help.3 Replies
dependent-tan•13mo ago
there is no more logging that needs to be silenced
We are no longer logging failed promises, as this isn't an actionable case. So the 404s will not be logged to the console by us
Every log that you see from react-query in dev mode is something you should really fix, like a config error, a wrong key, undefined being returned from the queryFn etc. We also log nothing in production
conscious-sapphireOP•13mo ago
Oh interesting, so the 404 Axios error won't log out from within react-query when upgrading to v5?
That's perfectly fine then 👍 thanks for the quick response @TkDodo 🔮
dependent-tan•13mo ago
yep, this is the way