<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLLogState",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLLogState"
  },
  "title" : "MTLLogState"
}
-->

# MTLLogState

A container for shader log messages.

```
protocol MTLLogState : NSObjectProtocol, Sendable
```

## Overview

Create an [`MTLCommandQueue`](/documentation/Metal/MTLCommandQueue) or [`MTLCommandBuffer`](/documentation/Metal/MTLCommandBuffer) with a log state to hold messages logged from shaders. Attach a log state to a command buffer by assigning it to the command buffer descriptor’s [`logState`](/documentation/Metal/MTLCommandBufferDescriptor/logState). Similarly, to attach a log state to a command queue, use the command queue descriptor’s [`logState`](/documentation/Metal/MTLCommandQueueDescriptor/logState).

When you attach a log state to a command queue, the command queue shares the log state with all the command buffers it creates. If you attach different log states to a command buffer and command queue, then the system uses the state attached to the command buffer.

Because logging incurs an overhead, regardless of whether the system prints messages, you need to explicitly enable logging with [`enableLogging`](/documentation/Metal/MTLCompileOptions/enableLogging).

---

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)