我想阅读我的应用程序的控制台。我的目标是找到所有这样的消息:
Warning: Attempt to present <ChildViewController: 0x7b44e380> on <TopViewController: 0x7a65e5b0> which is already presenting (null)
我在iOS7上创建了你无法阅读系统消息。
Using Objective C to read log messages posted to the device console
In iOS 7 you can use ASL to read messages output by your own app, including on previous runs of the same build of your app, but not messages output by the system or by any other apps.
在我看来,任何警告都是系统消息。 ios8可能会有变化吗?
答案 0 :(得分:1)
可以从&#34; syslog.sock&#34;中读取。 Github上的源代码在iOS8下运行:https://github.com/eswick/ondeviceconsole
ASL不再适用于iOS7以上的系统日志,iOS 7+应用程序只能通过增加沙盒来查看自己的日志消息。
如果您只想查看自己的应用日志,仍然可以使用ASL:
aslmsg q, m;
int i;
const char *key, *val;
q = asl_new(ASL_TYPE_QUERY);
aslresponse r = asl_search(NULL, q);
while (NULL != (m = aslresponse_next(r)))
{
NSMutableDictionary *tmpDict = [NSMutableDictionary dictionary];
for (i = 0; (NULL != (key = asl_key(m, i))); i++)
{
NSString *keyString = [NSString stringWithUTF8String:(char *)key];
val = asl_get(m, key);
NSString *string = val?[NSString stringWithUTF8String:val]:@"";
[tmpDict setObject:string forKey:keyString];
}
NSLog(@"%@", tmpDict);
}
aslresponse_free(r);