In Xcode7/iOS9 with the code below I was able to redirect the logs to an external file. Now with XCode8 with deployment target iOS 8.1, this seems to work only if I run on the simulator, on the actual device running iOS10 the file is empty. Is this a known issue? Is there a solution?
asl_add_log_file(NULL, STDERR_FILENO);
NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:@"logfile.txt"];
[[NSFileManager defaultManager] createDirectoryAtPath:[path stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:nil error:NULL];
int fd = open([path UTF8String], O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR);
if (fd != -1) {
asl_add_log_file(NULL, fd);
}
NSString *message = @"message123";
asl_log(NULL, NULL, ASL_LEVEL_DEBUG, "%s", [message UTF8String]);