Senthilkumar
Senthilkumar

Reputation: 2481

How to store crash log file inside the ios application?

suppose my application was crashed means at that time applicationWillTerminate function is called. In that function i want to save the crash log file in the Temporary directory. when app is launch at that time I want to upload the crash report file from the iOS device to my server location thorough the coding.

I'm using this code to save the crash log file.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *logPath = [documentsDirectory stringByAppendingPathComponent:@"console.log"];
freopen([logPath cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr);

but this code will work in the simulator. i can able to see this file in

/Users/UserNAme/Library/Application Support/iPhone Simulator/6.0/Applications/xxx-yyy-sss--eee/Documents/console.log

but i can't find this file in the ios devices.

Note: for finding file in the ios device I'm using iExplorer

Upvotes: 3

Views: 4395

Answers (2)

gaige
gaige

Reputation: 17481

Unfortunately, you cannot get at the crashlog on the device programmatically. To overcome this, there are a number of commercial, quasi-commercial, and open source solutions.

In particular, HockeyApp (owned by Microsoft now) and crittercism provide commercial solutions. In addition, TestFlightApp (although purchased by Apple) still provides this kind of functionality through its interface.

The HockeyApp source code is also available on github.

In the end, most of these system use an underlying crash catcher called plcrashreporter which is an open-source framework which places a near-exact copy of the iOS Crash Report in your directory.

If you want to manage things yourself, I'd strongly suggest plcrashreporter, otherwise the hosted and commercial solutions are available and you should look at them and decide yourself.

Upvotes: 9

ahwulf
ahwulf

Reputation: 2584

Another useful option (we use it) is Crashlytics.com, which is free and has a lot of control over the reporting (owned by twitter now, use with caution!).

Upvotes: 2

Related Questions