We are using CocoaLumberjack(3.7.0) for implementing logging into application. We want to keep max number of files to 90.
We are sure file size per day won't go beyond 100 MB.
So we referred below here
- You may optionally disable rolling due to time by setting
rollingFrequencyto zero (or any non-positive number). * If you do so, rolling is based solely onmaximumFileSize.
Below are the settings, we are making in our code.
DDLog.add(DDTTYLogger.sharedInstance!)
let tempDirectoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
let folderURL = tempDirectoryURL.appendingPathComponent("Logs")
let manager = DDLogFileManagerDefault(logsDirectory: folderURL.path)
fileLogger = DDFileLogger(logFileManager: manager)
fileLogger?.rollingFrequency = 0
fileLogger?.maximumFileSize = 1000 * 1000 * 100
fileLogger?.logFileManager.maximumNumberOfLogFiles = 90
fileLogger?.logFormatter = CustomDDLogFormatter.init()
DDLog.add(fileLogger!)
But we found that all of sudden some logs files got deleted interruptedly.
Did anyone know the reason and fix for this issue ?
Found answer here We checked internal code and documentation of LumberJack, found below property “logFilesDiskQuota”
The maximum space that logs can take. On rolling logfile all old log files that exceed logFilesDiskQuota will be deleted. Default value = 20 MB
Solution here.
“You may optionally disable this option by setting it to zero.”
After setting this value then this got fixed.