what happens to NSLog info when running on a device?
Asked Answered
E

5

44

what happens to NSLog info when running on a device? Where does the text go? Does it get saved? Is it therefore a big overhead when running on a device, or does it effectively get sent to null?

Endomorphism answered 15/3, 2011 at 21:33 Comment(1)
possible duplicate of Does NSLog executes in ipod / iphone ?Geniegenii
P
31

Your device will continue logging even when it's not connected to your mac. To see the logs, you need to open Xcode, click the 'Window' menu item, and then 'Organizer'. Then select your device and then select the 'Device Logs' tab. For some reason (for me at least) viewing the logs seems flaky, so if nothing shows up, you may need to completely quit Xcode and restart it.

Parnassian answered 15/3, 2011 at 21:52 Comment(3)
For me (XCode 4.6), "Device Logs" only shows crash logs & jettisons. Console seems to show only system output (not my app.) Any other hints? Thanks!Eddington
Oop -- duh. It's under console -- same organizer window.Eddington
For me, it showns up under Window > Devices and a list of devices and simulators appear on the left hand side.Ennius
W
53

Since Xcode 6 the device manager pane has been split into its own window. (Window > Devices, or Command-Shift-2.)

Once there, select your device, then show its log by clicking the disclosure triangle at the bottom of the window to the right of the sidebar.

enter image description here

Westbound answered 10/8, 2014 at 5:51 Comment(6)
Speaking of days, it's worth pointing out (or figuring out if anyone knows) that the log only persists for a little while. Maybe it gets purged more frequently if storage space is running low? (Just checked my phone and it only has 1 minute/500 lines of logs, even with 1.1GB available. It kept running for 5 minutes, never losing anything, and then I replugged it and it was back to ~2 mins/900 lines.)Westbound
And Saniul Ahmed points out on Twitter twitter.com/saniul/status/504745567218442240 that the view is actually resizable, but the hand is invisible, to the right and above the disclosure arrow.Westbound
Still works for Xcode 7.2 in late 2015. Screw Apple for making such an important, useful feature so incredibly unobvious to find.Pantaloons
How to see the memory leak issue in ios app??Disparate
ofcourse this only seems to be retaining half an hour of logs for me ... sigh :(Bautista
Couldn't find device logs (now in Xcode 8.3), found this answer (thank you!), went to upvote and discovered I already had sometime in the past. Apple really know how to make bad UI decisions at times.Inmost
P
31

Your device will continue logging even when it's not connected to your mac. To see the logs, you need to open Xcode, click the 'Window' menu item, and then 'Organizer'. Then select your device and then select the 'Device Logs' tab. For some reason (for me at least) viewing the logs seems flaky, so if nothing shows up, you may need to completely quit Xcode and restart it.

Parnassian answered 15/3, 2011 at 21:52 Comment(3)
For me (XCode 4.6), "Device Logs" only shows crash logs & jettisons. Console seems to show only system output (not my app.) Any other hints? Thanks!Eddington
Oop -- duh. It's under console -- same organizer window.Eddington
For me, it showns up under Window > Devices and a list of devices and simulators appear on the left hand side.Ennius
I
6

The text is logged. You can view the logs in xcode via the (almost-invisible) disclosure triangle in the Devices window as described in another answer.

You can also access the logs in a more usable view (including filtering) by opening Console.app on your connected Mac and selecting the device on the left.

Console.app screenshot

There will be some overhead with logging, but considering the volume of logging that's going on all the time in recent versions of iOS, unless you're generating an awful lot of output (or spending time generating the messages), it's unlikely to be significant.

Inmost answered 6/5, 2017 at 9:15 Comment(0)
C
5

It gets written to the Console log on the device. You can read it in the "Organizer" within Xcode when your device is connected.

Climb answered 15/3, 2011 at 21:49 Comment(0)
C
2

It gets logged out. You can retrieve it by connecting the device and looking in the organizing in xcode

Clank answered 15/3, 2011 at 21:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.