Search code examples
objective-cjsonnslog

How to get Device Logs in a text file from NSlog using Objective c?


I'm getting json data in my NSlog in Xcode using following code

NSString *jsonStr = [[NSString alloc] initWithData:activityData encoding:NSUTF8StringEncoding];
NSLog(@"Sync Json:%@",jsonStr); 

So if I have to get the same json data in my device log which can be sent as a text file as an email.


Solution

  • I used this code to fix my issue

    [[DBHelper getSharedInstance] AddLogFile:[NSString stringWithFormat:@"Sync Json:%@",jsonStr]];
    

    which sends the NSLog to my device log file.