28

is there a way to view the console output as we are running an iphone App on the device? If not directly, is there an app on the App store which lets you view the log after the App has finished running?

user315067
  • 715
  • 4
  • 9
  • 13
  • According to the developer's blog he used asl functions to access the logs, here http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man3/asl.3.html – progrmr May 15 '10 at 17:10
  • 2
    As of iOS 7.0, the app sandbox now prohibits access to any logs that aren't the app's: [via this Stack Overflow answer](http://stackoverflow.com/a/19045750/774) (also observed personally when using on-device apps to view the device's logs) – cbowns Oct 02 '13 at 23:53

3 Answers3

22

You can also see in Devices window.

Go in xcode -> Window -> Devices.

Select your device and open the console.enter image description here

Alex Terente
  • 11,770
  • 5
  • 47
  • 66
  • 2
    **-1 Does not answer the question.** OP is asking to view the console's contents _on-device_; this answer uses a development computer with Xcode. – Slipp D. Thompson Sep 22 '14 at 18:29
  • Where is this in Xcode 6? – ToddB Dec 17 '14 at 19:59
  • 1
    in Xcode 6 -> Window -> Devices -> Select the device -> a little arrow /\ at the bottom left, Click this and it will pop open the device console. – MujtabaFR Jan 22 '15 at 17:45
  • Get [iSyslog][1]. Works also on iOS7 and iOS8. Runs natively on any device (iPhone, iPod Touch, iPad). No jailbreaking required. [1]: https://itunes.apple.com/us/app/isyslog-system-monitoring/id468155763?mt=8 – Karoly Nyisztor Jul 04 '15 at 19:50
6
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *fileName =[NSString stringWithFormat:@"%@.log",[NSDate date]];

NSString *logFilePath = [documentsDirectory stringByAppendingPathComponent:fileName];

freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr);

Just add this block of code in applicationdidFinishLaunchingWithOptionslaunchOptions method in app delegate file, and it will create a log file in app Document Directory on iphone which logs all console log events. You need to import this file from itunes to see all console events.

Dont Forget to set "Application supports iTunes file sharing" to "YES" in Your plist

Goto - itunes -when ur device connected-Apps - select ur App - in Augument Document u will get ur file then save to ur disk

shyla
  • 1,290
  • 11
  • 9
3

if you have a paid iphone developer account, you can use the organizer window in xcode to view the console and app logs on your devices.

Jorge Cohen
  • 1,516
  • 10
  • 33
  • 1
    oh no thats not the issue ... I am developing a Location Based application, for which I need to run with my iphone. Its a little cumbersome to run with my macbook in one hand and iphone in the other. Any "on device log viewer"? – user315067 Apr 14 '10 at 05:23
  • 1
    you could make your app NSLog the data you want to see and view it later using the organizer. i think there's no way to see it live on-device unless you add you own ui to print it out. – Jorge Cohen Apr 14 '10 at 05:43
  • **-1 Does not answer the question** OP is asking to view the console's contents _on-device_; this approach uses a development computer with Xcode. – Slipp D. Thompson Sep 22 '14 at 18:29