Vidhi
Vidhi

Reputation: 47

How to retrieve old console logs from browser?

I had written some logs in console using JS to investigate one critical and very rarely occurring issue. Now the issue is reproduced on the client side few days back. But today, I want those old console logs when the issue was reproduced. How this logs can be retrieved? Does console logs get saved in any file?

Upvotes: 4

Views: 2991

Answers (1)

T.J. Crowder
T.J. Crowder

Reputation: 1074929

How this logs can be retrieved?

If the window is still open (which seems really unlikely), then you can retrieve them from the console in that window in the usual way (copy and paste). But the logs will be gone if the window has been closed. (The "Preserve Log" option only preserves the log across window reloads [F5, etc.], not being completely closed and then viewing the same URL later in a different window.)

Does console logs get saved in any file?

No. Well, it's hard to prove a negative, but I've never heard of them being stored to a file, and this thread from a Google employee (in 2019) about how to copy log information doesn't refer to any file (and given that it describes selecting, copying, and pasting), I'd expect it to; the search file -"file a good browser bug" site:https://developers.google.com/web/tools/chrome-devtools/console/ (that's the part of the Developer Center about the console) turns up no hits.


For the future, you can use any of several services that let you send log information to them and then preserve it for you. I just recently heard people raving about Sentry (they were talking about logging from Node.js, but from the website it looks like they support browsers too), but there are serverl others (Bugsnag, Rollbar, ...).

Upvotes: 3

Related Questions