Info | Value |
-------------------------|-------------------------------------|
Platform Name | ios
Platform Version | 11.0
CocoaLumberjack Version | 3.6.2
Integration Method | cocoapods
Xcode Version | Xcode 11.6
Repro rate | 100%
After the new version 3.6.2 the default timezone is set to UTC. How can I update the timezone to local time?
I am using the below code to initialize DDlogger in my code.
DDLogFileManagerDefault *fileManager = [[DDLogFileManagerDefault alloc] initWithLogsDirectory:[self fileLoggerFilesDirectory]];
[fileManager setMaximumNumberOfLogFiles:7]; //Max 7 files.
self.fileLogger = [[DDFileLogger alloc] initWithLogFileManager:fileManager];
[self.fileLogger setMaximumFileSize:(1024 * 1024 * 2)]; //2 MB file max
[self.fileLogger setRollingFrequency:(60.0f * 60.0f * 24.0f)]; //1 Day
[DDLog addLogger:self.fileLogger withLevel:DDLogLevelDebug];
@shikhilnuwal You'd need to set the logFormatter of the fileLogger yourself. To restore the pre-3.6.2 behavior, use the following code:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[dateFormatter setDateFormat:@"yyyy/MM/dd HH:mm:ss:SSS"];
self.fileLogger.logFormatter = [[DDLogFileFormatterDefault alloc] initWithDateFormatter:dateFormatter];
Of course you can also implement your own log formatter, or further adjust the dateFormatter.
Most helpful comment
@shikhilnuwal You'd need to set the
logFormatterof thefileLoggeryourself. To restore the pre-3.6.2 behavior, use the following code:Of course you can also implement your own log formatter, or further adjust the dateFormatter.