问题
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