Log to Xcode Console

Xcode from Apple is the one and only developer tool we are all using to build our apps for the Apple platform. Unfortunately Xcode has no built-in logging besides NSLog() and even that requires a tedious DIY solution. 

With SwiftyBeaver Framework Xcode finally gets powerful logging functionality to its Console including color, customizable formatting & so much more.

Screenshot of Xcode Console with colored level indicators (Xcode 8)


To start logging to Xcode Console you just need to instantiate  ConsoleDestination(), optionally adjust the properties and then add the instance to SwiftyBeaver itself:

let console = ConsoleDestination()


You can adjust the logging behavior with the following properties of   ConsoleDestination().

Property Default Description
Customize the  log format output, on default it shows every detail
.asynchronously true Runs on own serial background thread for better performance. Set to  false during development for easier debugging.
.minLevel .verbose Any level with a priority lower than that level is not logged. Possible values are SwiftyBeaver.Level.verbose, .debug, .info .warning, .error. 
.levelString.verbose, .debug, .info, .warning, .error "VERBOSE", "DEBUG", etc. Sets a custom string representing the log level. On default it is the log level as uppercase word.

Example for custom logging to Xcode Console:

let console = ConsoleDestination()
console.format = "$DHH:mm:ss$d $L: $M"  // hour, minute, second, loglevel and message
console.minLevel = .info // just log .info, .warning & .error
log.addDestination(console) // add to SwiftyBeaver

Still need help? Contact Us Contact Us