iOS CocoaLumberjack: New log file is creating on every time app launch, if backgroundModes enabled and app running in simulator

安稳与你 提交于 2020-01-06 08:59:48

问题


I have configured library like below

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

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


回答1:


Try setting

fileLogger.logFileManager.maximumNumberOfLogFiles = 1;

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



来源:https://stackoverflow.com/questions/54919967/ios-cocoalumberjack-new-log-file-is-creating-on-every-time-app-launch-if-backg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!