[英]Programmatically reading crash logs in Objective C in an OSX / cocoa app
I want to be able to read a crash log and send it to my server. 我希望能够读取崩溃日志并将其发送到我的服务器。 I've seen libraries that do this, and I'm actually basing my code on them -- except many of them seem out of date, which is why I believe I'm currently having a problem with OSX sandboxing.
我已经看到了执行此操作的库,实际上我将代码建立在它们的基础上-除非其中许多似乎已经过时,这就是为什么我认为我目前在OSX沙箱方面存在问题。
There seem to be 2 parts to any generated crash log. 任何生成的崩溃日志似乎都有两部分。 In
/Users/zane/Library/Containers/**[BUNDLE_ID]**/Data/Library/Application Support/CrashReporter
there is a .plist
with not much information. 在
/Users/zane/Library/Containers/**[BUNDLE_ID]**/Data/Library/Application Support/CrashReporter
没有一个.plist
信息。 One thing it does contain, though, is a Path
to ~/Library/Logs/DiagnosticReports/**FULL_CRASH_FILE**.crash
它确实包含的一件事是
~/Library/Logs/DiagnosticReports/**FULL_CRASH_FILE**.crash
的Path
However, when I try to open this full path via [NSString stringWithContentsOfFile...]
I get a read access error: Error Domain=NSCocoaErrorDomain Code=257 "The file “Aftermath_2014-02-12-210934_inZania.crash” couldn't be opened because you don't have permission to view it." UserInfo=0x600000264700 {NSFilePath=/Users/zane/Library/Logs/DiagnosticReports/Aftermath_2014-02-12-210934_inZania.crash, NSUnderlyingError=0x600000246900 "The operation couldn't be completed. Operation not permitted"}
但是,当我尝试通过
[NSString stringWithContentsOfFile...]
打开此完整路径时,出现读取访问错误: Error Domain=NSCocoaErrorDomain Code=257 "The file “Aftermath_2014-02-12-210934_inZania.crash” couldn't be opened because you don't have permission to view it." UserInfo=0x600000264700 {NSFilePath=/Users/zane/Library/Logs/DiagnosticReports/Aftermath_2014-02-12-210934_inZania.crash, NSUnderlyingError=0x600000246900 "The operation couldn't be completed. Operation not permitted"}
Error Domain=NSCocoaErrorDomain Code=257 "The file “Aftermath_2014-02-12-210934_inZania.crash” couldn't be opened because you don't have permission to view it." UserInfo=0x600000264700 {NSFilePath=/Users/zane/Library/Logs/DiagnosticReports/Aftermath_2014-02-12-210934_inZania.crash, NSUnderlyingError=0x600000246900 "The operation couldn't be completed. Operation not permitted"}
I take it that this is a problem with entitlements/sandboxing. 我认为这是权利/沙盒的问题。 Is there any way I can gain access to this file, or otherwise get a full stack trace to send to my crash reporter?
有什么办法可以访问此文件,或者获得完整的堆栈跟踪信息发送给我的崩溃报告器?
You can check the permissions of the log file!! 您可以检查日志文件的权限!! It may need root permissions to access!
它可能需要root权限才能访问!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.