I used this code, but it no longer works on iOS 10 due to a change in all the APIs associated with the logging system.
+ (NSString *)getConsoleLog { NSString *consoleLog = @""; char fdate[24]; NSString *myPID = [NSString stringWithFormat:@"%d", getpid()]; aslmsg query, msg; query = asl_new(ASL_TYPE_QUERY); asl_set_query(query, ASL_KEY_PID, myPID.UTF8String, ASL_QUERY_OP_EQUAL); aslresponse r = asl_search(NULL, query); while ((msg = aslresponse_next(r))) { NSString *secondsString = [NSString stringWithFormat:@"%s", asl_get(msg, ASL_KEY_TIME)]; NSString *nanoSecondsString = [NSString stringWithFormat:@"%s", asl_get(msg, ASL_KEY_TIME_NSEC)]; NSTimeInterval seconds = [secondsString doubleValue]; NSTimeInterval nanoSeconds = [nanoSecondsString doubleValue]; NSTimeInterval msgTime = seconds + nanoSeconds / NSEC_PER_SEC; time_t timestamp = (time_t)msgTime; struct tm *lt = localtime(×tamp); strftime(fdate, 24, "%Y-%m-%d %T", lt); consoleLog = [consoleLog stringByAppendingFormat:@"%s.%03d %@\n", fdate, (int)(1000.0 * (msgTime - floor(msgTime))), [NSString stringWithFormat:@"%s", asl_get(msg, ASL_KEY_MSG)]]; } aslresponse_free(r); asl_free(query); return consoleLog; }
Can anyone help?
ios10
khaled
source share