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?
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.
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.
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.
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.
It gets written to the Console log on the device. You can read it in the "Organizer" within Xcode when your device is connected.
It gets logged out. You can retrieve it by connecting the device and looking in the organizing in xcode
Related
When my app crashes, I would like to save the latest console for debug purposes (especially to read system messages such as unrecognized selector)
Is it possible to access the console programatically?
UPDATE:
I've found the answer in the documentations: using STDERR_FILENO.
"Logs an error message to the Apple System Log facility (see man 3 asl). If the STDERR_FILENO file descriptor has been redirected away from the default or is going to a tty, it will also be written there."
It sounds like you want to change the destination for the standard output stream. I've never tried that in iOS, but I'd expect to be able to do that using freopen(). Here's a SO question that may help.
You'll also want to build some debug feature into your app that makes it easy to recover the output. You could post it to a web server, for example, or have the app e-mail it to you.
When your app crashes in a device, a crash log is saved. When you plug your device in, launch XCode, open the "Organizer" window and click on devices. Then look for your device on the left, and click on "crash logs." Together with the information from the .dSYM file that's generated when you build, you can often recover how and where your app crashed. If you really just want to save the information in the console window of XCode when you crash, just click inside the console window, hit Cmd-A (select all), and Cmd-C (copy), then paste into a text editor window.
I'm debugging an overuse of released objects using NSZombieEnabled. It's OK if you have an active connection with mac and are running from xcode4. But I'm hunting one bug that occurs after long run and I would like to test in on device without the connection. Just wondering is it possible to have some code for catching an event when a message is sent to zombie and then, ten display some NSLog with relevant information?
You can open up "Organizer" and view the console output. You get the same data that you would from the Console when debugging while attached to the Mac.
Window -> Organizer -> Click the arrow next to your device and select "Console"
Are there any libraries out there that would allow end users to send crash reports to developers?
For example, a user is using my app. It crashes. On boot up, a library loads before everything else and notices there is a crash report and prompts the user to send the crash log to me.
Is this possible? I think the Facebook app does something like this.
Thanks!
You actually have access to crash logs in iTunes Connect. Log in, go to Manage your Applications, pick an app, "View Details", and you should see a "Crash Reports" link to the right of the details pane.
That said, Apple only refreshes these daily, and will only give you access to reports of the most common crashes. If you want finer control, or need the user to submit reports directly, try plcrashreporter. You could ask the user for a submission this way, or just go ahead and automatically send all reports to your server. From the plcrashreporter site:
Introduction
Plausile CrashReporter implements
in-process crash reporting on the
iPhone and Mac OS X. The following
features are supported:
Implemented as an in-process signal
handler. Does not interfer with
debugging in gdb.. Handles both
uncaught Objective-C exceptions and
fatal signals (SIGSEGV, SIGBUS, etc).
Full thread state for all active
threads (backtraces, register dumps)
is provided. If your application
crashes, a crash report will be
written. When the application is next
run, you may check for a pending crash
report, and submit the report to your
own HTTP server, send an e-mail, or
even introspect the report locally.
Another alternative is HopToad - they host the site that will accept the crash reports and notify you.
iOS 5 and later
Tapping Settings > General > About > Diagnostics & Usage will allow you to choose between Automatically Send and Don't Send.
iOS 4 and earlier
By default, opting in is a one-time decision. If you'd like to change your decision, you can reset warnings for your iOS 4 or earlier device so that you will be asked again.
How to reset warnings within iTunes
Connect your iPad, iPhone, or iPod touch to your PC or Mac.
Wait until your device has appeared on the left side of the iTunes window under Devices.
Right-click (Mac or PC) or Control-click (Mac) the icon for your device.
From the shortcut menu, choose Reset Warnings:
The next time you sync after resetting warnings, you should see:
To disagree and stop sending Apple diagnostic and usage information, click No Thanks.
If you don't see the window above
Disconnect your device from your computer.
Open an application on your device.
Press and hold the Sleep/Wake button until the red slider appears, and then press and hold the Home button until the application quits. If you're using iOS 2.x or earlier, press and hold the Home button until the application quits.
Connect your device and sync it with iTunes.
The option to agree or disagree to diagnostics collection should appear again.
Chearz;)
Another alternative that we have been using at my company is Crittercism - http://www.crittercism.com/. They have been very responsive to feature requests and have really helped us prioritize which issues to address.
Their SDK also has the functionality I set out to look for so long ago! :)
Does anyone knows how to get crash logs from customers? Instead of manually asking them to sync and go to this directory and this directory and send it.
Is there any automatic way to do send a crash report to our server?
You can perform your own crash-logging with PLCrashReporter. Typically, you write the crash log to a file and then send it to a server the next time the app starts.
In order to prevent an infinite crash-reporting loop (there was one in an early version), you want to do things in a specific order:
Read the file to memory and delete it. (Hopefully this won't crash.)
Parse the crash report and send it to the server. (If it crashes now, the file has been deleted, so it shouldn't happen again.)
Finally, enable crash reporting (so if it crashes in steps 1 or 2, the crash isn't logged).
In any case, you should have a "Oops, it crashed! Do you want to send a crash report?" dialog. I think automatic crash-logging is permitted by the default EULA, but it doesn't hurt to be nice to your users.
If you're worried about losing reports forever if the user says "no", instead of deleting the report, you can do logrotate-style style renaming (i.e. rename report8 to report9, rename report7 to report8, ..., rename report to report0). Then have a "send last N crash reports" button (either set N=10 or count the number of reports), so even if they've accidentally disabled it (or they had no internet at the time), they can still send the report.
iOS 5 and later
Tapping Settings > General > About > Diagnostics & Usage will allow you to choose between Automatically Send and Don't Send.
iOS 4 and earlier
By default, opting in is a one-time decision. If you'd like to change your decision, you can reset warnings for your iOS 4 or earlier device so that you will be asked again.
How to reset warnings within iTunes
Connect your iPad, iPhone, or iPod touch to your PC or Mac.
Wait until your device has appeared on the left side of the iTunes window under Devices.
Right-click (Mac or PC) or Control-click (Mac) the icon for your device.
From the shortcut menu, choose Reset Warnings:
The next time you sync after resetting warnings, you should see:
To disagree and stop sending Apple diagnostic and usage information, click No Thanks.
If you don't see the window above
Disconnect your device from your computer.
Open an application on your device.
Press and hold the Sleep/Wake button until the red slider appears, and then press and hold the Home button until the application quits. If you're using iOS 2.x or earlier, press and hold the Home button until the application quits.
Connect your device and sync it with iTunes.
The option to agree or disagree to diagnostics collection should appear again.
Chearz;)
reference:
http://support.apple.com/kb/HT4305
In iTunes, with their device tethered, if the user control-clicks on the name for their device, they will be able to select "Reset Warnings". Afterwards, a dialog box will pop up when the user next Syncs their device asking if it's OK to send data to Apple. If they click OK, then iTunes will upload all the crash logs from their device to Apple's servers.
Afterwards, you should be able to find your crash logs in iTunes Connect, and download them yourself. New crash logs will appear if your app still has problems and the user Syncs again, all automagically.
If you are talking about normal AppStore sales, Crash Reports are available through iTunes Connect.
Just go to "Manage Your Applications" -> "Your Application" -> And click "View Details" with the version currently active in the AppStore.
You will then get the details of your application, including the crash reports that are send in by your customers.
I have some users testing my app on Windows and Mac platforms. The app crashes at some points but the Windows users cannot get any crash logs. Here's what they do
Run the app and play around till it crashes
Sync their device with iTunes
Look for logs here (on a Vista) C:\Users\\AppData\Roaming\Apple computer\Logs\CrashReporter\MobileDevice\
But there is nothing inside the Apple Computer folder.
Any ideas? Thanks.
Aside from you omitting parts of the path in that it should correctly be containing the login username - ow, now noticed you possibly did try to embed it, hence the double backspace after Users....
Ask your user if he possibly is using multiple computers for syncing his device. In case he does, he should check the machine he used first as those Logs are only synced with the "main"-machine, I believe. Bit of a shot in the dark but worth the attempt, I think.
Ow, and there may be another possible reason I just saw within another thread - credits to Kendall:
If there is not crash log, it could mean the app was shut down for using too much memory - in that case you should see a message come up in the device console indicating your application is being shut down.