---
title: MTLLogState
framework: metal
role: symbol
role_heading: Protocol
path: metal/mtllogstate
---

# MTLLogState

A container for shader log messages.

## Declaration

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

## Mentioned in

Logging shader debug messages

## Overview

Overview Create an MTLCommandQueue or 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. Similarly, to attach a log state to a command queue, use the command queue descriptor’s 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.

## Topics

### Instance Methods

- [addLogHandler(_:)](metal/mtllogstate/addloghandler(_:).md)

## Relationships

### Inherits From

- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Shader logging

- [MTLLogStateDescriptor](metal/mtllogstatedescriptor.md)
