<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "os",
  "identifier" : "/documentation/os/Logger/log(level:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "os"
    ],
    "preciseIdentifier" : "s:2os6LoggerV3log5level_ySo0a1_C7_type_ta_AA12OSLogMessageVtF"
  },
  "title" : "log(level:_:)"
}
-->

# log(level:_:)

Writes a message to the log using the specified log type.

```
func log(level: OSLogType, _ message: OSLogMessage)
```

## Parameters

`level`

The message’s log level, which determines the severity of the message and whether the system persists it to disk. For possible values, see [`OSLogType`](/documentation/os/OSLogType).

`message`

The interpolated string that the logger writes to the log. Each of the message’s interpolations can specify individual formatting and privacy options. For more information, see [Message Argument Formatters](/documentation/os/message-argument-formatters).

## Discussion

> Important:
> Don’t create an instance of ``doc://com.apple.os/documentation/os/OSLogMessage``. Instead, provide an interpolated string as the `message` parameter and the system converts it automatically.

---

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)