iOS CocoaLumberjack:每次启动应用程序时都会创建新的日志文件,如果启用了backgroundModes且应用程序在模拟器中运行 [英] iOS CocoaLumberjack: New log file is creating on every time app launch, if backgroundModes enabled and app running in simulator

查看:346
本文介绍了iOS CocoaLumberjack:每次启动应用程序时都会创建新的日志文件,如果启用了backgroundModes且应用程序在模拟器中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经配置了如下库

    let fileLogger: DDFileLogger = DDFileLogger() 
    fileLogger.rollingFrequency = -1
    fileLogger.maximumFileSize = 1024 * 1024
    fileLogger.logFileManager.maximumNumberOfLogFiles = 7
    DDLog.add(fileLogger)

文件只有在达到1MB大小时才必须滚动.最近,我观察到一件事,如果应用程序在启用了后台模式的模拟器中运行.无论文件大小如何,每次启动应用程序时都会创建新的日志文件.这是已知的东西吗?因为NSFileProtectionTypeDDFileLogger.m类中的doesAppRunInBackground()条件内为nil.但它在设备上运行正常

File has to roll only if it reaches 1MB size. Recently i observed one thing, if app running in simulator with background mode enabled. New log file is creating on every time app launch irrespective of file size. Is this known thing?. Because NSFileProtectionType is nil inside doesAppRunInBackground() condition in DDFileLogger.m class. But it is working fine in device

推荐答案

尝试设置

fileLogger.logFileManager.maximumNumberOfLogFiles = 1;

如果这不起作用,请尝试在DDFileLogger.m类的doesAppRunInBackground()函数中将NSFileProtectionType设置为true或1.

If that does not work then try setting NSFileProtectionType to either true or 1 inside doesAppRunInBackground() function inside the DDFileLogger.m class.

这篇关于iOS CocoaLumberjack:每次启动应用程序时都会创建新的日志文件,如果启用了backgroundModes且应用程序在模拟器中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆