如何不在Xcode输出中显示日志,但仍然将它们发送给Hockeyapp报告

时间:2016-05-24 10:42:00

标签: ios hockeyapp lumberjack

我正在使用Hockeyapp进行崩溃报告,并在应用崩溃时收集日志。使用以下方法。

- (void)setupLumberjack {
    // Configure CocoaLumberjack
    [DDLog addLogger:[DDASLLogger sharedInstance]];
    [DDLog addLogger:[DDTTYLogger sharedInstance]];

    // Initialize File Logger
    // initialize before HockeySDK, so the delegate can access the file logger!
    _fileLogger = [[DDFileLogger alloc] init];
    _fileLogger.maximumFileSize = (1024 * 128); // 128 KByte
    _fileLogger.logFileManager.maximumNumberOfLogFiles = 5;
    [_fileLogger rollLogFileWithCompletionBlock:nil];
    [DDLog addLogger:_fileLogger];
}

设置日志级别:

static const int ddLogLevel = LOG_LEVEL_ALL;

现在我想让所有日志级别仍然发送到Hockeyapp报告,但是在xcode控制台中输出任何输出。

我怎样才能实现这一目标?可能在这里遗漏了一些东西。

使用版本1.9.2,但如果有必要,则愿意更新到2.x.

2 个答案:

答案 0 :(得分:1)

Xcode日志始终显示在Xcode控制台中 你没有办法禁用它们。

但是你可以隐藏输出窗口:P

您还可以为Debug构建设置设置自定义编译器标志。

enter image description here

然后您编写一个DLog()宏,只有当此标志存在时才会回显NSLog() =>仅在使用Xcode进行调试时 这样用户就不会在他们的设备上登录任何日志。

答案 1 :(得分:0)

我正在寻找的答案发布在comment

只需删除此行即可: [DDLog addLogger:[DDTTYLogger sharedInstance]];