Created
July 20, 2016 03:12
-
-
Save nicolastinkl/8bcb8aeab976d6de6f2108ad12a56d02 to your computer and use it in GitHub Desktop.
ios 实时输出日志信息 命令行
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool 在函数里添加 | |
redirectConsoleLog() | |
/// redirect Log. | |
func redirectConsoleLog() { | |
#if DEBUG | |
let documentDir: String = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] | |
print("documentPath : \(documentDir)") | |
//重定向NSLog | |
let logPath: NSString = documentDir.stringByAppendingString("/console.log")// NSURL(fileURLWithPath: documentDir).URLByAppendingPathComponent("console.log").absoluteString | |
freopen(logPath.fileSystemRepresentation, "a+", stderr) | |
#endif | |
} | |
2. 日志文件输出在/Users/asiainfo/Library/Developer/CoreSimulator/Devices/CA1056FB-C344-48B2-B271-F3065C4FE640/data/Containers/Data/Application/E4099B7B-CC76-49C5-BA83-B3D14698B233/Documents/console.log | |
使用命令: tail -f console.log | |
过滤 : 使用命令: tail -f console.log | grep "ios" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment