Question on rolling frequency & initialization of the logger

259 views
Skip to first unread message

dravid27

unread,
Nov 14, 2013, 3:38:28 PM11/14/13
to cocoalu...@googlegroups.com
HI,
Here's my scenario:
We are trying to track down a bug in surveys that our users take on iphones through our app. Since they take a lot of surveys, we coded in a way to capture the logging into a max of 10 log files each of size 500kb and anything beyond that, would loose our data(and that is ok). After taking some surveys, the users would replicate to send the log files to the server. Once the log files are uploaded, our code would delete those log files on the unit.


here's my logger initialization code

- (void)applicationDidFinishLaunching:(UIApplication *)application {

    // Setup logging (with our custom formatter)

LogMessageFormatter *formatter = [[LogMessageFormatter alloc] init];

    [[DDTTYLogger sharedInstance] setLogFormatter:formatter];

[DDLog addLogger:[DDTTYLogger sharedInstance]]; 

    

    self.fileLogger = [[DDFileLogger alloc] init]; 

    NSString* baseDocDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];

    NSString* logDir = [NSString stringWithFormat:@"%@/UnitLog",baseDocDir];

    DDLogFileManagerDefault* logFileManager = [[[DDLogFileManagerDefault alloc ]initWithLogsDirectory:logDir] autorelease];

    self.fileLogger = [[[DDFileLogger alloc] initWithLogFileManager:logFileManager]autorelease];

    //...other settings...

    self.fileLogger.rollingFrequency=0;

    self.fileLogger.maximumFileSize=1024 * 500// 500KB;

    self.fileLogger.logFileManager.maximumNumberOfLogFiles=10;

    [self.fileLogger setLogFormatter:formatter];

    [DDLog addLogger:self.fileLogger];

}


1) the issue i'm having is: some times some logging is missing and that too the starting part. For suppose, the user has take 5 surveys. On the server, i see 4 log files of data. When i open the first log file, it has only a part of the logging for the first survey. It's missing the starting of the part of the log!


my questions is since i have set maximumNumberOfLogFiles=10, and i'm deleting the log files once the user replicates the logs to the server even though the number of logs created are <10, is this causing my log data to be lost? 


2) As you can see above, i've the xcode console logger and the file loggers configured in the applicationDidFinishLaunching method of my app. And then i use DDLogWarn statements in my survey module classes to log the survey logging to both the xcode console and the log file. the issue i'm having is the first time i open my app, go to surveys list and take some surveys, it is logging to both the xcode and the log file well. But when I sync to upload the survey data and the logs to the server, and then come back to take some more surveys, it just logs to the xcode console and doesnt create a new log file and so doesn't log to the file! I thought configuring the loggers in the applicationDidFinishLaunching method is just enough or do i need to do any thing else in this regards? can some one help me in this regards?


thanks in advance.



Reply all
Reply to author
Forward
0 new messages