简体   繁体   中英

Get iPhone Logs(not crash logs)

I have a couple of NSLog statements in my app. In Xcode we can track NSLog() in console. When my client runs the app one of the label value is not displaying in UI. The problem is i am not able to replicate that issue at all.

Now i want the client to send log when he faces that issue. I know how to get crash logs. But i want the log which will have the result of all NSLog() statements when my client runs the app in his iPhone.

Hope my above problem is clear. Is there a way to get such logs?Any Suggestions guys?

Thanks.

Got a breakthrough!!. We need to re-direct NSLog to a file like this and then access the file.

- (void)redirectNSLogToDocumentFolder{
    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);
}

http://objcolumnist.com/2009/12/19/redirecting-nslog-to-a-log-file/

I've made a debug library that can be used to view your application logs from within. Also it has ability to send logs via email, so you can easily grab logs from your client. Hope this will help someone.

DVFloatingWindow

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM