<!--
{
  "availability" : [
    "iOS: 12.0.0 -",
    "iPadOS: 12.0.0 -",
    "macCatalyst: -",
    "macOS: 10.14.0 -",
    "tvOS: 12.0.0 -",
    "visionOS: -",
    "watchOS: 5.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "os",
  "identifier" : "/documentation/os/os_log(_:dso:log:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "os"
    ],
    "preciseIdentifier" : "s:2os0A4_log_3dso0B0__ySo0a1_B7_type_ta_SVSo03OS_a1_B0Cs12StaticStringVs7CVarArg_pdtF"
  },
  "title" : "os_log(_:dso:log:_:_:)"
}
-->

# os_log(_:dso:log:_:_:)

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

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

## Parameters

`type`

The log level to assign to the message. For more information about log levels, see [`OSLogType`](/documentation/os/OSLogType).

`log`

A custom log object. If unspecified, system uses the shared default log.

`message`

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

`args`

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.

## Discussion

Call this function to capture information about things that might result in a failure. For more information about format strings, see `Formatting Log Messages`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)