76

When using Safari Web Inspector to read the JavaScript console output, the log is reset upon navigation i.e. going from page index.html to mail.html clears the console output. In the Chrome Developer Tools, I can easily preserve the log by right clicking on the console space and selecting Preserve Log Upon Navigation. With this option, console log output remains intact until I manually clear the output simplifying the process of debugging JavaScript that refreshes or redirects to another page.

Is there a similar feature in Safari Web Inspector?

Daniel Compton
  • 13,878
  • 4
  • 40
  • 60
Zorayr
  • 23,770
  • 8
  • 136
  • 129
  • I don't think so, at least i haven't found it to be the case. – Naman Goel Dec 18 '13 at 19:04
  • you could overwrite the console.log method, store all data received, save it in localstorage upon navigation 'a'.click, and re-apply it on some event like document.ready, but its rather hacky – Paul Scheltema Dec 20 '13 at 17:00

5 Answers5

62

I don't know when this was added, but it is present in Safari on El Capitan (Safari 9.0). It works the same as in Chrome (right click in the console window and select "Keep Log on Navigation").

Update: As per Daniel Compton's answer, in Safari 11+ this is now under the settings icon as 'Console: Clear when page navigates'.

Update: The setting is now back to "Preserve log" in the Network tab in the developer console in Safari 14+

AlBlue
  • 23,254
  • 14
  • 71
  • 91
Jon
  • 16,212
  • 8
  • 50
  • 62
  • 33
    They could have hide it a bit more! – joseantgv Sep 29 '16 at 13:37
  • The location of this setting does not even make sense... why is it in the console tab and not in the network or the general settings? Anyway many thanks for the answer. – Aurelio Apr 26 '17 at 10:44
  • 3
    As Daniel Compton points out, as of Safari 11 this is no longer the case. Please see [his answer](https://stackoverflow.com/a/46508266) for recent instructions. – Matthias Oct 09 '17 at 04:47
  • Unfortunately both options don't seem to be available in Safari 7.1 - I guess I should upgrade. – gekkedev Oct 15 '19 at 14:49
15

In Safari 11.1.2 they moved it again(!) back to the Console tab under the "Preserve log" checkbox. The Network log has similarly moved back to the Network tab.

Console tab


In Safari 11 they moved it to the Settings panel under "Console: Clear when page navigates". It also has a sister setting "Network: Clear when page navigates".

enter image description here

Daniel Compton
  • 13,878
  • 4
  • 40
  • 60
7

No, there is no such feature (in Safari 5.0 at least). Looking at some Google results, I don't think this feature exists in any Safari version.

rvighne
  • 20,755
  • 11
  • 51
  • 73
7

As of October 2022, Safari 16 and MacOS Monterey 12.6, for some reason the setting is now hidden here:

safari 16+ preserve logs location

safari 16+ preserve logs option

As @joseantgv wished in the accepted answer's comments, they excelled again and were able to hide it a little bit more ‍♂️

Fabio
  • 393
  • 3
  • 9
0

For old Safari versions, you can right-click on the console and select the Keep Log on Navigationenter image description here

gabo bernal
  • 721
  • 6
  • 5