---
title: "log(level:_:)"
framework: os
role: symbol
role_heading: Instance Method
path: "os/logger/log(level:_:)"
---

# log(level:_:)

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

## Declaration

```swift
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 doc://com.apple.os/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 doc://com.apple.os/documentation/os/message-argument-formatters.

## Discussion

Discussion important: Don’t create an instance of OSLogMessage. Instead, provide an interpolated string as the message parameter and the system converts it automatically.

## See Also

### Logging a Message

- [log(_:)](os/logger/log(_:).md)
- [OSLogType](os/oslogtype.md)
- [OSLogMessage](os/oslogmessage.md)
