我有这个方法:
q = asl_new(ASL_TYPE_QUERY);
asl_set_query(q, ASL_KEY_SENDER, "MyApp", ASL_QUERY_OP_EQUAL);
// Count the number of results
r = asl_search(NULL, q);
while (NULL != (m = aslresponse_next(r))) {
counter++;
}
r = asl_search(NULL, q);
while (line++ < counter && NULL != (m = aslresponse_next(r)))
{
// Take only the latest results
if (!(line < counter-NUMBER_OF_LOG_MESSAGES)) {
log = [NSMutableDictionary dictionary];
for (i = 0; (NULL != (key = asl_key(m, i))); i++)
{
keyString = [NSString stringWithUTF8String:(char *)key];
if ([self.logKeyFilter containsObject:keyString]) {
val = asl_get(m, key);
string = [NSString stringWithUTF8String:val];
[log setObject:string forKey:keyString];
}
}
date = [dateFormat stringFromDate:[NSDate dateWithTimeIntervalSince1970:[[log objectForKey:@"Time"] doubleValue]]];
[logs addObject:[NSString stringWithFormat:@"%@ %@ %@", date, [self.logLevelKeyFilter objectForKey:[log objectForKey:@"Level"]], [log objectForKey:@"Message"]]];
}
}
aslresponse_free(r);
return logs;
返回“MyApp”的最新日志。 NUMBER_OF_LOG_MESSAGES此处仅采用最新日志。
问题是,当我使用带有PID X的MyApp崩溃并且我重新启动MyApp以捕获日志时,我只有新的PID Y的日志。
那么,我如何搜索每个日志文件以查找MyApp的日志。
谢谢。
答案 0 :(得分:0)
问题与此链接相同: Logs that are visible on iOS5 are not visible on iOS 6 (only on device)
按照它来回答。