Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue in Rolling Frequency. #243

Closed
Anantvijay opened this issue Mar 20, 2014 · 14 comments
Closed

Issue in Rolling Frequency. #243

Anantvijay opened this issue Mar 20, 2014 · 14 comments
Milestone

Comments

@Anantvijay
Copy link

I have integrated the framework and followed the very same steps that was provided in the gitHub home page. i wrote the code as follows:

DDFileLogger _fileLogger = [[DDFileLogger alloc] init];
[fileLogger setRollingFrequency:60_60];
[fileLogger.logFileManager setMaximumNumberOfLogFiles:7];
[fileLogger setMaximumFileSize:3145728];
[DDLog addLogger:fileLogger];
[DDLog addLogger:[DDTTYLogger sharedInstance]];

But the rolling feature doesnt seems to be working. It is still appending logs to the same file even after it crossed an hour's time.
DDLogVerbose(@"%@",[fileLogger.logFileManager logsDirectory]);

@mschmiderer
Copy link

Rolling broken for me too.

@rivera-ernesto
Copy link
Member

Are you using the latest master version? (:head option id using CocoaPods)

Any idea @dvor ?

@CMoebius
Copy link

I am having the same issue with setting the maxim file size and I just now updated to the latest version. Here's my code:

fileLogger = [[DDFileLogger alloc] init];
fileLogger.rollingFrequency = 0; //60 * 60 * 24; // 24 hour rolling
fileLogger.maximumFileSize = 1024 * 512;
fileLogger.logFileManager.maximumNumberOfLogFiles = 7;
[DDLog addLogger:fileLogger];

I want the log files capped at 512K, but when I look at the files using iExplorer, the files just keep getting appended to and grow without limit. As you can see, I used to have this set for 24 hour rolling, but the logs were getting way too big. We upload them to our server if there is an issue and we don't want them to be huge.

@CMoebius
Copy link

I also wanted to add that the method to roll the file log is not working:

[fileLogger rollLogFileWithCompletionBlock:^{
}];

@KristinaAtTile
Copy link

I'm seeing the same thing -- new log messages being written to the latest log file even if it's beyond the rolling frequency age limit.

From what I can tell, the issue is that DDFileLogger rollLogFileNow sets currentLogFileInfo.isArchived=YES (which is reasonable), but then the next time currentLogFileInfo gets called, we find that mostRecentLogFileInfo.isArchived is true, so we set shouldArchiveMostRecent=NO, and then fall into this code path:

if (!_doNotReuseLogFiles && !shouldArchiveMostRecent) {
    NSLogVerbose(@"DDFileLogger: Resuming logging with file %@", mostRecentLogFileInfo.fileName);
    currentLogFileInfo = mostRecentLogFileInfo;
}

I've hacked this conditional in my own project to add a check for !mostRecentLogFileInfo.isArchived, and now I believe it's working as expected. However I am very new to CocoaLumberjack so I don't know if this may have any unintended side effects.

Hopefully someone who's more familiar with the code can investigate my findings and decide whether this is a legitimate solution.

@rivera-ernesto
Copy link
Member

Could you make a pull request so we can discuss the changes there?

@DD-P
Copy link
Contributor

DD-P commented Jun 1, 2014

Also broken for me. Git bisect running against RollingTestMac suggested SHA bb167eb

@georgekola
Copy link
Contributor

I am having the same when using the latest master version ( cocoapods with :head). I verified that the bug was introduced by SHA bb167eb as suggested by @DD-P . I have opened a pull request that fixes this issue -- #295

@an0
Copy link
Contributor

an0 commented Jun 23, 2014

Same issue here. Huge log files.

@rspeyer
Copy link
Contributor

rspeyer commented Jun 23, 2014

I am also experiencing this behavior. It appears, empirically, that as the logs file grows the overall performance of CocoaLumberjack, and my application, declines in a notable way. Is this causal or expected?

@bpoplauschi
Copy link
Member

Guys, could you please check this using the latest master? I've merged the pull request from @georgekola and want to make sure this fixes the rolling issue you are having.

@bpoplauschi bpoplauschi added this to the 1.9.1 milestone Jun 23, 2014
@DD-P
Copy link
Contributor

DD-P commented Jun 24, 2014

This seems to work correctly now for me (I tested against RollingTestMac). Thank you to @georgekola for the fix.

@dvor
Copy link
Member

dvor commented Jun 26, 2014

I've checked - everything is working.

@KimiChiu
Copy link

I'm still having this issue.
I'm using CocoaLumberjack/Swift 3.5.1.

let fileLogger: DDFileLogger = DDFileLogger() // File Logger
fileLogger.rollingFrequency = 60 * 60 * 24 // 24 hours
fileLogger.logFileManager.maximumNumberOfLogFiles = 7
fileLogger.maximumFileSize = 1024 * 1024 // 1 Mega bytes

#if DEBUG
DDLog.add(DDOSLogger.sharedInstance, with: .verbose)
DDLog.add(fileLogger, with: .verbose)
#else
DDLog.add(DDOSLogger.sharedInstance, with: .info)
DDLog.add(fileLogger, with: .info)
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests