Step 1: Include following function in AppDelegate:
- (void) redirectConsoleLogToDocumentFolder
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *logPath = [documentsDirectory stringByAppendingPathComponent:@"console.log"];
freopen([logPath fileSystemRepresentation],"a+",stderr);
}
Step 2: Call this function at the start of function applicationDidFinishLaunchingWithOptions...
Thats it, Every NSLog() will now get redirected to this console.log file, which you can find in the documents directory.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…