IOS真机调试查看日志

1:获取沙盒路径,新建日志文件  

NSString *docStr=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
   
    NSString *fileName =[NSString stringWithFormat:@"%@.log",[NSDate date]];
   
    NSString *logFilePath = [docStr stringByAppendingPathComponent:fileName];
   
2:将NSLog日志输入到指定的日志文件
    freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr);


-info.plist 中添加 UIFileSharingEnabled  值为 true, 配置分享为true,在iTunes 同步的时候会同步document下的文件目录 则可看到生成的日志文件;

猜你喜欢

转载自tlin.iteye.com/blog/2231871