CocoaLumberjack的简单实用

版权声明:本文为博主原创文章,欢迎转载。 https://blog.csdn.net/chen12302asd/article/details/82112852

修改Podfile文件

platform :ios, '9.0'
target 'demo0827' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!
  # Pods for demo0827

pod 'CocoaLumberjack'
end

导入头文件

#import <CocoaLumberjack/CocoaLumberjack.h>

打印日志

[DDLog addLogger:[DDTTYLogger sharedInstance]]; // TTY = Xcode console
[DDLog addLogger:[DDASLLogger sharedInstance]]; // ASL = Apple System Logs

DDFileLogger *fileLogger = [[DDFileLogger alloc] init]; // File Logger
fileLogger.rollingFrequency = 60 * 60 * 24; // 24 hour rolling
fileLogger.logFileManager.maximumNumberOfLogFiles = 7;
[DDLog addLogger:fileLogger];

DDLogLevel ddLogLevel = DDLogLevelAll;
NSLog(@"%@", fileLogger.currentLogFileInfo.filePath);
DDLogVerbose(@"Verbose");
DDLogDebug(@"Debug");
DDLogInfo(@"Info");
DDLogWarn(@"Warn");
DDLogError(@"Error");

查看日志文件。

/Users/user/Library/Developer/CoreSimulator/Devices/4E2102E8-6C99-4393-9AF9-0FC40FD61D6F/data/Containers/Data/Application/AAA74851-FB5D-4EC8-AF0E-30C97696D0EB/Library/Caches/Logs/com.ccyag.note.demo0827 2018-08-27--06-39-34-488.log

将文件上传至服务器。

参考文章:
iOS用CocoaLumberJack抓取crash日志上传

猜你喜欢

转载自blog.csdn.net/chen12302asd/article/details/82112852
今日推荐