31

Is there any way to log to Safari's JavaScript console when running with the built-in JavaScript debugger? I've read the Firefox JavaScript logging question and hoping that there is a simple ("native") way to do it in WebKit/Safari.

Thanks

Community
  • 1
  • 1
adib
  • 8,285
  • 6
  • 52
  • 91

3 Answers3

28

Make sure you have "All" selected in the top right corner of the dev tools.

The top right section of the Safari dev tools If it's set to "Error" then your Safari will only show console.error().

Boris Verkhovskiy
  • 14,854
  • 11
  • 100
  • 103
  • Currently dealing with this. Is there any way to change the setting to show `All` by default. When I close the browser window and start a new session it reverts back to just `Errors` view and I'm wondering where the hell all of my debug console messages went. SUPER FRUSTRATING. – Mark Tomlin Nov 26 '19 at 18:44
  • 1
    @MarkTomlin no clue. Try looking for a setting from the command line https://pawelgrzybek.com/change-macos-user-preferences-via-command-line/ – Boris Verkhovskiy Nov 26 '19 at 19:51
24

It works just the same in Safari as it does in Chrome and Firefox. By default the developer tools is not turned on, so make sure you go to Preferences -> Advanced -> Show Develop Menu in Menu Bar. Then you can pull up the console with Command+Option+C. (That shortcut obviously assumes Mac, not sure the PC shortcut, but it's in the dropdown as well)

Robert
  • 21,110
  • 9
  • 55
  • 65
22

You can use the same console object described in that question. The messages will show up in the console tab.

console.log("hello console");

console.log will work "natively" in Firefox (with Firebug), IE8+, and WebKit browsers (including Safari).

Cristian Sanchez
  • 31,171
  • 11
  • 57
  • 63