- (void) redirectConsoleLogToDocumentFolder{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDesktopDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSDate *now = [NSDate date];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd HH.mm.ss.SSS"];
NSString *timeString = [dateFormat stringFromDate:now];
NSString *fileName = [NSString stringWithFormat:@"%@ %@", timeString, @".log"];
NSString *logPath = [documentsDirectory stringByAppendingPathComponent:fileName];
freopen([logPath fileSystemRepresentation],"a+",stderr);
}
- (void)applicationWillFinishLaunching:(NSNotification *)notification{
[self redirectConsoleLogToDocumentFolder];
}