objective c iphone : can we view console log on device

29,385

Solution 1

Update to use Xcode 12.5.1 and Console 1.1:

In Xcode go to Window->Devices and Simulators, select your device and press on "Open Console" button.

Or directly open Console by pressing cmd+space -> type "Console" and press enter.

In the Console app select your device from left pane and press on "Start streaming".

enter image description here


You can also see in Devices window.

Go in xcode -> Window -> Devices.

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

Solution 2

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

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

Share:
29,385
user315067
Author by

user315067

Updated on December 26, 2021

Comments

  • user315067
    user315067 over 2 years

    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
    user315067 about 14 years
    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"?
  • Jorge Cohen
    Jorge Cohen about 14 years
    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.
  • prabhu
    prabhu about 11 years
    thanks, but I am unable to find the app document directory, can you please help me to find that .log file to import from iTunes
  • Slipp D. Thompson
    Slipp D. Thompson almost 10 years
    -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
    Slipp D. Thompson almost 10 years
    -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.
  • Robert Wasmann
    Robert Wasmann over 9 years
    Seems with iTunes 12 we can't import files from the document directory anymore. Now everything is iCloud. How can users get this log file?
  • ToddB
    ToddB over 9 years
    Where is this in Xcode 6?
  • MujtabaFR
    MujtabaFR over 9 years
    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.
  • Karoly Nyisztor
    Karoly Nyisztor almost 9 years
    Get [iSyslog][1]. Works also on iOS7 and iOS8. Runs natively on any device (iPhone, iPod Touch, iPad). No jailbreaking required. [1]: itunes.apple.com/us/app/isyslog-system-monitoring/…
  • goelectric
    goelectric about 8 years
    Works fine for me with Xcode 7.3 and iTunes 12.3.3.17