XLFacility is a versatile logging framework for Objective-C and Swift. It is designed to work seamlessly across various Apple platforms such as macOS, iOS, watchOS, and tvOS.

Key Features

  • Efficient and lightweight logging framework
  • Supports both Objective-C and Swift
  • Compatibility across multiple Apple platforms
  • Flexible log level filtering
  • Customizable logging destinations
  • Thread-safe operations
  • Easy to integrate into existing projects


Installing XLFacility is straightforward using CocoaPods.

  1. Add the following line to your Podfile:

pod ‘XLFacility’

  1. Run the command pod install in your project directory.


Before you start using XLFacility in your project, make sure you import the library.

import XLFacility

Logging Messages

To log a message, simply call the appropriate logging function:

XLLogger.log(“This is a log message.”)
XLLogger.debug(“This is a debug message.”)
XLLogger.info(“This is an info message.”)
XLLogger.warning(“This is a warning message.”)
XLLogger.error(“This is an error message.”)

Log Level Filtering

XLFacility allows you to filter log messages based on their severity level. By default, all log levels are enabled.

To set a specific log level, use the following code:

XLLogger.logLevel = .info

This will only output log messages with a severity level equal to or higher than info. You can choose from the following log levels:

  • .off – No logging
  • .error – Only error messages
  • .warning – Includes warning and error messages
  • .info – Includes info, warning, and error messages
  • .debug – Includes debug, info, warning, and error messages
  • .log – Logs all messages (default level)

Custom Logging Destinations

XLFacility provides multiple logging destinations, allowing you to configure where the log messages get stored.

To add a custom logging destination, follow these steps:

  1. Create a class that conforms to the XLLogDestination protocol.
  2. Implement the required methods that handle logging.
  3. Add the new destination to the logger using the addDestination(_:) method.

Example: Adding a File Logger

Here’s an example of how to create a file logger using XLFacility:

  1. Create a class that conforms to the XLFileLogDestination protocol.
  2. Implement the required methods:

class FileLogger: XLFileLogDestination {
var logDirectoryURL: URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!

func log(_ details: XLLogRecordDetails, message: String) {
// Implement your logging logic here, e.g., save the log to a file
// Make sure to handle the logDirectoryURL appropriately

func supports(_ logLevel: XLLogLevel) -> Bool {
// Implement which log levels this destination supports
return true // Or perform your own filtering logic

  1. Add the destination to the logger:

let fileLogger = FileLogger()


XLFacility is an open-source project, and contributions are welcome!

If you encounter any issues, have suggestions for improvements, or would like to contribute code, please visit the GitHub repository for XLFacility.


XLFacility is released under the MIT License.