简体   繁体   中英

CocoaLumberjack - How can I see the log files data in Xcode?

I am using CocoaLumberjack for storing iOS(objective c) app logs and all the logs are getting stored properly. I can see the log data files in my local machine but unable to see the content of each file in Xcode console. Here is the function that prints all files' data in the console:

DDFileLogger *ddFileLogger = [DDFileLogger new];
    NSArray <NSString *> *logFilePaths = [ddFileLogger.logFileManager sortedLogFilePaths];
    NSMutableArray <NSData *> *logFileDataArray = [NSMutableArray new];
    for (NSString* logFilePath in logFilePaths) {
        NSURL *fileUrl = [NSURL fileURLWithPath:logFilePath];
        NSData *logFileData = [NSData dataWithContentsOfURL:fileUrl options:NSDataReadingMappedIfSafe error:nil];
        if (logFileData) {
            [logFileDataArray insertObject:logFileData atIndex:0];
        }
    }
NSMutableData *errorLogData = [NSMutableData data];
            for (NSData *errorLogFileData in logFileDataArray) {
                [errorLogData appendData:errorLogFileData];
            }
    NSLog(@"REACHED HERE!!");
    NSLog(@"%@", errorLogData);
    NSLog(@"PRINTING ENDED"); 

That's the output I am getting:

2018-01-26 14:40:47.325 zapin[10427:8168442] REACHED HERE!!
2018-01-26 14:40:47.325 zapin[10427:8168442] <38312f20 0a442032 3031382d 
30312d32 36203133 3a35373a 30303a38 3038206b 44617368 626f6172 6455726c 
3a206874 74703a2f 2f646173 68626f61 72642e73 74616769 6e672e7a 6170696e 
6170702e 636f6d2f 64657669 63652d61 7574682e 68746d6c 200a4520 32303138 
636f6d2f 64657669 63652d61 7574682e 68746d6c 200a4520 32303138 2d30312d 
32362031 343a3430 3a34373a 33323520 74657374 696e6720 70617373 6564202d 
2d206461 74612063 616e2062 65207365 656e210a>
2018-01-26 14:40:47.387 zapin[10427:8168442] PRINTING ENDED

I am new to logging and CocoaLumberjack, and stack overflow in general, so forgive me if I didn't state the problem properly. How can I see the content of each log data file in Xcode console? Also, how can I store the actual data on Amazon AWS S3? Can anyone please help me with this?

If you want to see the logs in the xcode console, you should add TTYLogger, if you also want to see the logs in the system console, you should add ASLLogger.

[DDLog addLogger:[DDTTYLogger sharedInstance]];
[DDLog addLogger:[DDASLLogger sharedInstance]];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM