繁体   English   中英

Crashlytics iOS - 日志被捕异常

[英]Crashlytics iOS - log caught exception

我找到了一种在Crashlytics Android SDK中记录自定义捕获异常的方法,但我找不到类似iOS SDK的内容。 有没有办法在iOS上使用Crashlytics记录捕获的异常?

请参阅Android说明: http//support.crashlytics.com/knowledgebase/articles/202805-logging-caught-exceptions

Mike来自Crashlytics和Fabric。

您现在可以在iOS,tvOS或OS X应用程序中捕获已记录的NSErrors。 你想用:

[CrashlyticsKit recordError:error];

要么

Crashlytics.sharedInstance().recordError(error)

这将允许您为每个用户会话捕获相当数量的已记录NSErrors。 这些仅在应用重新启动时发送。 记录的错误错误按错误域和代码分组。 这意味着错误问题可以跨越许多不同的呼叫站点。

文档

最后,Crashlytics添加了所需的功能3.5.0 !!

[CrashlyticsKit recordError:error];

要么

Crashlytics.sharedInstance().recordError(error)

参考

/**
 *
 * This allows you to record a non-fatal event, described by an NSError object. These events will be grouped and
 * displayed similarly to crashes. Keep in mind that this method can be expensive. Also, the total number of
 * NSErrors that can be recorded during your app's life-cycle is limited by a fixed-size circular buffer. If the
 * buffer is overrun, the oldest data is dropped. Errors are relayed to Crashlytics on a subsequent launch
 * of your application.
 *
 * You can also use the -recordError:withAdditionalUserInfo: to include additional context not represented
 * by the NSError instance itself.
 *
 **/
- (void)recordError:(NSError *)error;
- (void)recordError:(NSError *)error withAdditionalUserInfo:(nullable CLS_GENERIC_NSDICTIONARY(NSString *, id) *)userInfo;

https://docs.fabric.io/ios/changelog.html#january-7-2016


历史

这实际上并不像我预期的那样工作:消息被保存到Crashlytics但只有在应用程序重新启动后它才会保存最后一条消息。

到目前为止,这里提到的解决方案都没有。 使用Crashlytics无法在iOS中跟踪处理的异常。


您可以使用它来记录任何异常

[[Crashlytics sharedInstance] recordCustomExceptionName:@"HandledException" reason:@"Some reason" frameArray:@[]];

在Crashlytics中,您将在崩溃报告中看到它,但使用NON-FATALS类型。

事件,如果它不是它的预期用法异常以与Android处理的异常相同的方式记录。

这在3.0.7版中可用。

recordCustomExceptionName:原因:frameArray:

此方法可用于在报表中记录单个异常结构。 当您的代码与Lua,C#或Javascript等非本地语言交互时,这尤其有用。 此调用可能很昂贵,只能在进程终止前不久使用。 此API不用于记录NSException对象。 Crashlytics会自动捕获所有可安全报告的NSExceptions。

https://docs.fabric.io/appledocs/Crashlytics/Classes/Crashlytics.html#//api/name/recordCustomExceptionName:reason:frameArray

使用Crashlytics SDK无法在iOS中记录捕获的异常。 CLS_LOG可用于记录自定义消息,但这些日志消息将仅使用下一个崩溃数据发送到Crashlytics。 如果没有崩溃,这些日志消息将永远不会出现在Crashlytics仪表板中。 我得到了Crashlytics支持团队的正式确认。 在他们的路线图中记录了iOS中的异常记录。

我已经通过不同的站点来支持此功能,以支持替代Crashlytics的IOS。

到目前为止,我发现批评是最好的.. @ Dima我认为它是Crashlytics的替代品......它。

以下是一些有助于在项目中集成生产的链接......!

http://docs.crittercism.com/ios/ios.html#logging-handled-exceptions

http://www.raywenderlich.com/34050/overview-of-ios-crash-reporting-tools-part-2

@try {

     } 
@catch (NSException *exc) 
     {
        [Crittercism logHandledException:exc]
    }

请参考这些链接,看看它对您有用......!

在catch块中使用以下行来处理自定义捕获的异常

NSUncaughtExceptionHandler *handler = NSGetUncaughtExceptionHandler();
handler(exception);

正如iOS http://support.crashlytics.com/knowledgebase/articles/222764-can-i-use-a-custom-exception-handler所述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM