2

When testing my iOS application on a device connected to Xcode, logs from NSLog or CCLog appear in the console, which is very useful for me to debug.

When the device is not connected to Xcode, obviously I don't get such logs. And when it crashes, I simply don't know why.

Because of this, I made a question here: Is there an output log like Xcode's available locally in my iPhone?. But I have noticed that those "Device Logs" are not the logs I expected. In fact, they are greatly different from the logs I see in my Xcode console, and none of them reflects a NSLog or CCLog I have done in my project. So I guess I was looking in the wrong place.

Are NSLogs or CCLogs stored somewhere I can retrieve? I don't really understand the "Device Logs", but they really don't seem to tell me anything useful or specific.

Community
  • 1
  • 1
Saturn
  • 17,888
  • 49
  • 145
  • 271
  • The answer by Chris De Laet on here might help you out: http://stackoverflow.com/questions/6663754/is-nslog-stored-on-the-device-iphone-etc-if-so-where – Tom Irving Dec 11 '12 at 18:14
  • One related thing to keep in mind is ensure that in production releases you have NSLog compiled out. – ahwulf Dec 11 '12 at 18:31

5 Answers5

3

Connect your device to your computer and in XCode, windows Organizer, you can see the devices. You can select your device and then click on Console. It should show you all the NSLog statements

Srikanth
  • 1,725
  • 2
  • 10
  • 11
0

Your crashes are logged in your device so you can retrieve them when you connect your phone to the XCode.

1 - Plug it in

2 - Open you XCode and go to Organizer (cmd + shift + 2)

3 - Click on Devices and then on the upper left click on Device Logs.

enter image description here

Andre Cytryn
  • 2,506
  • 4
  • 28
  • 43
0

To add something to the other (pretty standard) answers, here's a solution for which you don't need Xcode: the idevicesyslog utility from the libimobiledevice library can also display all logs.

Bonus: if you have a jailbroken phone, you can install syslogd from Cydia and all your syslog will be saved to a file named /var/log/syslog.

0

Best option is to run your app from Xcode connected to a real device and look at console output (Shift-Command-Y to display/hide console view by default).

Second best option is to connect device afterwards to your mac and use iPhone Configuration Utility to view your app specific console log.

Third best option is to use some 3rd party iPhone app, which can read console log in the device (when you're on field trip or something). Warning: I made the "Console On Device" app just for this purpose, needed to debug crashes while travelling. It can display app specific logs and allows emailing them.

JOM
  • 8,139
  • 6
  • 78
  • 111
0

In my experience, most users never look at logs, so they are useless and just waste time, space, and battery. Some people look at the logs and get worried for no good reason at all, give you bad reviews ("I looked at the logs and there are lots of bugs in the code"), all with no benefit to anyone.

So get rid of the NSLogs. Best to define a macro that does NSLog in a debug build and nothing in a release build. There shouldn't be any NSLog in your source code except for that macro.

gnasher729
  • 51,477
  • 5
  • 75
  • 98
  • Good tip, but the question is about how to retrieve the logs, not about whether you should use them or not. – Saturn Mar 21 '15 at 21:11