How to view logs from iPhone? - iphone

I have place several NSLog() in my iOS application, is it possible to see all the logs later on my Mac that was generated when the app ran on iPhone handset even when iPhone was not connected with Mac.
Thanks

No. You can however redirect NSLog to a file, using something like this: http://blog.coriolis.ch/2009/01/09/redirect-nslog-to-a-file-on-the-iphone/
Then you can access the file via Xcode, or upload it with your app. File usage and privacy issues apply.
Keep in mind that NSLog is supposed to be turned off in published apps, so you may want to use a different logging app. A number of NSLog alternatives are available.

Unfortunately this is not possible.
The only thing that you can get is a Crash Log.
If you need a better logging system, I suggest to take a look to CocoaLumberjack, a very powerful logging framework that gives you the opportunity to save log in files and, eventually, send them to a server.
You also have many different levels like: log info, log error, log warning, etc...

You can view crash logs from your iPhone in the Organizer.
If you want to view your own log statements, you could consider TestFlight ( http://testflightapp.com ). They offer an SDK which includes features for remote logging.

I'm fairly certain that's not possible. The device needs to be connected to the Mac in order to run in Xcode's debug mode, and you need to be in debug mode to view the console, which contains your NSLogs.

There is a crash log for every crash that occurs on the phone, which is readable after connecting to your mac. These NSLog's don't appear in this log nor do they appear anywhere else in a (semi) permanent manner.

It's possible using custom macros and a custom class which will write each message in the documents directory in a file.
If the file sharing is enabled in the app you can later download them in iTunes.

Seeing the logs in mac might not be possible. But you can send the log to testflight using TFLog(). But you will need to distribute your app through testflightapp. And integrate the sdk. I think that is what you are looking for. try out - testflightapp.com

Related

Are logs made with NSLog or CCLog stored in the iPhone? Can I retrieve them?

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.
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
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.
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.
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.
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.

iPhone how to debug customers phones

I've gotten a couple of bug reports from customers that I am unable to duplicate with my devices. These aren't crashes hence no crash reports. I'm trying to figure out what options I have to solve these bugs. Keep in mind that these customers vary widely in their technological prowess and willingness to help out.
The best I can think of is making an ad-hoc build with logging enabled to a file in their documents directory, but then I need a way to get that file off their phone.
Specifically, Short of remote debugging (that would be great) I want to get a log file or some other diagnostics to see what is going on.
What options do I have?
EDIT: Great information already given, but I am looking for something like 'writing log statements to a remote server', probably just for an ad-hoc (for debugging) build. So, basically, by looking at their log, hopefully, I can deduce where things go wrong. I could build such a system, but wondering what is already out there.
Once you have the ad-hoc build, you can send the app to your customers, so that they can install it in iTunes and from there on to their iPhones.
Dragging/dropping on iTunes your app will place it in the App folder.
As to retrieving your log file, you could implement copying of your log file back to itunes (like many apps do), so the customer could get it from there and send it back to you... or you could simply post the file through HTTP to a server of yours under the customer's control.
AdHoc + TestFlightApp.com - extremely easy, powerful.
Flurry is an option.

iPhone console for nslog?

How can i see nslog messages when I am testing on device? My only way right now is to have a UITextView and put message in there, there must be a better way..Thanks.
I went to seetings and turned on console but still don't know how to see them. Thanks.
These calls will output to your devices system log. You'll be able to get these from the XCode Organizer when you plug your phone back in.
There are also a few apps you can install from App Store on your device (search for free ones, with Console in their title, and ability to send emails with logs).
This is useful especially if you want to debug some errors on your beta testers devices, or don't want to connect your device every time you want to see what's in the console log.

Is there a way to automatically include the console output with the crash log on ios

The crash log returned when your app has an error on iOS is wonderful however it would be 100 times better if it contained the console output from when your app started as part of the log. Is there a way to automatically have that information in the crash log, or have a semi-automatic system that testers could use when sending in crash logs?
I think you might want to take a look at http://apphance.com. It's exactly what you are looking for - including capability of sending problem reports from device by testers, including screenshots, you can track history of session including full console logs, you can even see crashes from out-of-memory problems which are otherwise difficult to get without physical access to the device. It's closed beta for now but soon it will be open for everyone. You can request access directly at the page.
Disclaimer: I am CTO of Polidea, company which is behind apphance and co-creator of the service.
#Medran i am not sure if this will help but if you can get the Brad Larsons videos on Advance iPhone App Development than there he says some thing about .dSYM file that will help you find the places where crash occurs. .dSYM file is made when you build your app using Xcode. See if you can find that file in your project folder its named something like this MYapp.app.dSYM

My App works perfectly on my Droid X, reviewers complain of crashes on other devices - how to debug?

Some say it doesnt start on their HTC Hero, another says it doesnt open in their Cliq, etc. I built the entire app using my Droid X to debug. Now that the app is released, and the code is interacting with so many different types of hardware, how do I figure out what may be going wrong for these users?
In my Crash errors log I have one record of a crash, and I believe I've already fixed this. It was certainly not responsible for the crashes that users are complaining about.
Maybe you have to check manually or maybe it's a problem of multiresolution because different mobile have different resolutions. Otherwise if it is possible then you have to include crash log report in your application which send crash logs to your email id.
Or you can ask them to install crash log reporter and set your emailid to target for crash report. Try this link, first one for manually adding code to your application.
https://github.com/tomquist/Android-Error-Reporter
http://www.androidzoom.com/android_applications/tools/log-collector_tlt.html
Do you have any Logcat outputs in release mode? May be they help you out..
Alternatively, you can test it out on 3rd party mobile testing vendors.. Where in you can buy some hours and do some quick testing...