No NSLog
or print
content will write to system.log
, which can be open by Select Simulator -> Debug -> Open System log
on Xcode 11.
I figure out a way, write logs into a file and open the xx.log
with Terminal.app
.Then the logs will present in Terminal.app
lively.
I use CocoaLumberjack achieve this.
Add DDFileLogger
DDOSLogger
and print logs path. config()
should be called when App lunch.
static func config() {
#if DEBUG
DDLog.add(DDOSLogger.sharedInstance) // Uses os_log
let fileLogger: DDFileLogger = DDFileLogger() // File Logger
fileLogger.rollingFrequency = 60 * 60 * 24 // 24 hours
fileLogger.logFileManager.maximumNumberOfLogFiles = 7
DDLog.add(fileLogger)
DDLogInfo("DEBUG LOG PATH: " + (fileLogger.currentLogFileInfo?.filePath ?? ""))
#endif
}
Replace print
or NSLog
with DDLogXXX
.
$ tail -f {path of log}
Here, message will present in Terminal.app lively.
One thing more. If there is no any message log out, make sure
Environment Variables
->OS_ACTIVITY_MODE
ISNOT disable.