Where is Logfile stored using cocoaLumberjack

前端 未结 9 1029
不知归路
不知归路 2020-12-22 18:07

I am Using cocoaLumberjack logging framework for iOS logging. For storing logs in a file I used this code.

DDFileLogger* fileLogger = [[DDFileLogger alloc] i         


        
9条回答
  •  再見小時候
    2020-12-22 18:56

    If you're using CocoaLumberjack, you have DDFileLogger.h and you can expose the currentLogFileInfo: method that is implemented already:

    @interface DDFileLogger : DDAbstractLogger 
    ...
    - (DDLogFileInfo *)currentLogFileInfo;
    @end
    

    Then, you can programmatically access the path to the current file with:

    // configure logger
    DDFileLogger *fileLogger = [DDFileLogger new];
    [DDLog addLogger:fileLogger];
    [DDLog addLogger:[DDTTYLogger sharedInstance]];
    DDLogInfo(@"log file at: %@", [[fileLogger currentLogFileInfo] filePath]);
    

    Which, on my iPhone, printed:

    log file at: /var/mobile/Applications/3BE1219F-78BE-491C-B68C-74D6FA0C2EF1/Library/Caches/Logs/log-5D1286.txt
    

    to both the console and the file.

提交回复
热议问题