Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save / export Chrome's JavaScript console input history

Is there anyway that I can save or export the history of JavaScript console input (console history) in Google Chrome? I'm not looking to save the output or the errors, so hovering my mouse over the console box, right-clicking, and selecting Save as... is not the solution. I don't want to have to scroll up with the arrow keys and copy-and-paste the contents each time.

like image 942
Melab Avatar asked Aug 11 '18 18:08

Melab


People also ask

Where are Chrome console logs stored?

Debug logs are stored in the user data directory as chrome_debug. log. The file is overwritten every time Chrome restarts. So, if you have an issue with the browser, check the log before you restart Chrome.

How do I save Devtools logs?

Chrome/EdgeSelect Tools > Developer Tools. The Developer Tools window opens as a docked panel at the side or bottom of Chrome. Click the Network tab. Select Preserve log.

How do I save my Developer Tools output?

Open the Developer Tools, click on the Network panel, then right-click anywhere within the panel and choose "Save as HAR with Content" to export the panel to the file system.


1 Answers

I figured out a weird solution that seems to work:

  • Open Chrome Developer Tools (press CTRL + SHIFT + J)

  • If the developer tools window is docked, undock into a separate window (open the menu to choose docking option)

  • Inside the developer tools window, press CTRL + SHIFT + J which will open a developer tools window for the developer tools window!

  • Inside the second developer tools window, enter the following command inside console:
    localStorage.getItem("consoleHistory")

This should print the console history, encoded as JSON inside the console. You can decode the JSON into an array using this command:

JSON.parse(localStorage.getItem("consoleHistory"))

Or copy the JSON to clipboard using:

copy(localStorage.getItem("consoleHistory"))
like image 98
Salman A Avatar answered Oct 05 '22 12:10

Salman A