<!--
{
  "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/OSLogPrivacy",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "os"
    ],
    "preciseIdentifier" : "s:2os12OSLogPrivacyV"
  },
  "title" : "OSLogPrivacy"
}
-->

# OSLogPrivacy

The privacy options that determine when to redact or display values in log messages.

```
@frozen struct OSLogPrivacy
```

## Overview

The [`OSLogPrivacy`](/documentation/os/OSLogPrivacy) structure determines the visibility of interpolated values in log messages. Because people have access to log messages that your app generates, use the privacy options to hide potentially sensitive information. For example, you might use it to hide account information or personal data.

Use the available properties and methods to fetch an appropriately configured version of this structure, and pass it with your interpolated value in the log message. The following example shows how to mark a variable that contains the user’s bank account information as private:

```swift
Logger().info("User bank account number: \(accountNumber, privacy: .private)")
```

When you want to replace the generic redaction string with a hashed version of the original value, specify privacy options using the [`auto(mask:)`](/documentation/os/OSLogPrivacy/auto(mask:)), [`private(mask:)`](/documentation/os/OSLogPrivacy/private(mask:)), and [`sensitive(mask:)`](/documentation/os/OSLogPrivacy/sensitive(mask:)) methods. Using a hash string makes it possible to correlate log messages that contain the same original value, which helps you protect the user’s privacy and still diagnose issues surrounding a specific value.

## Topics

### Getting the Privacy Options

[`auto`](/documentation/os/OSLogPrivacy/auto)

The standard option to let the system determine whether to redact or display a value.

[`private`](/documentation/os/OSLogPrivacy/private)

The standard option to always redact the interpolated value.

[`public`](/documentation/os/OSLogPrivacy/public)

The standard option to always show the interpolated value.

[`sensitive`](/documentation/os/OSLogPrivacy/sensitive)

The option to always redact interpolated values that contain sensitive information.

### Creating a Custom Privacy Mask

[`auto(mask:)`](/documentation/os/OSLogPrivacy/auto(mask:))

Returns a privacy structure that determines whether to redact or show values according to their type, and customizes the display of redacted values.

[`private(mask:)`](/documentation/os/OSLogPrivacy/private(mask:))

Returns a privacy structure that marks an interpolated value as private, and customizes the display of redacted values.

[`sensitive(mask:)`](/documentation/os/OSLogPrivacy/sensitive(mask:))

Returns a privacy structure that marks an interpolated value as sensitive, and customizes the display of redacted values.

[`OSLogPrivacy.Mask`](/documentation/os/OSLogPrivacy/Mask)

A mask that establishes how the system displays a redacted value in a log message.



---

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)