<!--
{
  "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/error(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "os"
    ],
    "preciseIdentifier" : "s:2os6LoggerV5erroryyAA12OSLogMessageVF"
  },
  "title" : "error(_:)"
}
-->

# error(_:)

Writes information about an error to the log.

```
func error(_ message: OSLogMessage)
```

## Parameters

`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.

Use this method to write messages with the [`error`](/documentation/os/OSLogType/error) log level to both the in-memory and on-disk log stores.

---

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)