Sends a message to the logging system, optionally specifying a custom log object, log level, and any message format arguments.


func os_log(_ message: StaticString, dso: UnsafeRawPointer? = #dsohandle, log: OSLog = .default, type: OSLogType = .default, _ args: CVarArg...)



A constant string or format string that produces a human-readable log message.


A custom log object. If unspecified, the shared default log is used.


The log level. If unspecified, the default log level is used.


If message is a constant string, do not specify arguments.

If message is a format string, pass the expected number of arguments in the order that they appear in the string.


Call this function to capture information about things that might result a failure. Default-level messages sent by this function are initially stored in memory. Without a configuration change, they are moved to the data store as memory buffers fill. They remain there until the storage quota is exceeded, at which point, the oldest messages are purged.For more information about format strings, see Formatting Log Messages.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software