# Logging Service

This module includes configuration variables for the Logging service.

## Summary

| ### Macros ||
|---|---|
| `https://openthread.io/reference/config/group/config-logging#group__config-logging_1ga6eed783d422ab585b9955a1be6accf6d 1` | Define to enable CLI logging and `otLogCli()` OT function. |
| `https://openthread.io/reference/config/group/config-logging#group__config-logging_1ga5335535008e1dfef2069b2c6c155750b 0` | Define to 1 to enable the instance-aware platform logging API. |
| `https://openthread.io/reference/config/group/config-logging#group__config-logging_1ga6223b9f4d26d5a9e44299f9ab06f0576 OT_LOG_LEVEL_CRIT` | The log level (used at compile time). |
| `https://openthread.io/reference/config/group/config-logging#group__config-logging_1gac24b36f83a70e0d096b97487d32c76ee 0` | Define as 1 to enable dynamic log level control. |
| `https://openthread.io/reference/config/group/config-logging#group__config-logging_1ga9802d7340e221b89b968ddcb06d437e1 OPENTHREAD_CONFIG_LOG_LEVEL` | The initial log level used when OpenThread is initialized. |
| `https://openthread.io/reference/config/group/config-logging#group__config-logging_1gafe721b4c242a3a67c19c913d518b36a3 0` | Define to 1 to enable the log level override feature and its associated APIs. |
| `https://openthread.io/reference/config/group/config-logging#group__config-logging_1gade73d58bab6dff2cca9ee3014977007f 150` | The maximum log string size (number of chars). |
| `https://openthread.io/reference/config/group/config-logging#group__config-logging_1ga0e86c76aa5d016ca2ecc8b3d84c04d90 OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED` | Selects if, and where the LOG output goes to. |
| `https://openthread.io/reference/config/group/config-logging#group__config-logging_1ga9995d202055365c787243821b14a3471 2` | Log output goes to the "application" provided otPlatLog() in NCP and CLI code. |
| `https://openthread.io/reference/config/group/config-logging#group__config-logging_1ga4ef5b0bc34ed833fc87e8ce2d71300df 1` | Log output goes to the debug uart - requires OPENTHREAD_CONFIG_ENABLE_DEBUG_UART to be enabled. |
| `https://openthread.io/reference/config/group/config-logging#group__config-logging_1ga351a6d401ce5769a1903a643b4c56aad 0` | Log output goes to the bit bucket (disabled) |
| `https://openthread.io/reference/config/group/config-logging#group__config-logging_1gad5b195689fe848bdaac28961778762ce 3` | Log output is handled by a platform defined function. |
| `https://openthread.io/reference/config/group/config-logging#group__config-logging_1gad4733980efc828fd9f19652179d2de56 1` | Define to enable dump logs (of packets). |
| `https://openthread.io/reference/config/group/config-logging#group__config-logging_1ga9490a831f435c91ed870c1ca0ba57172 1` | Define to enable platform logging and `otLog{Level}Plat()` OT functions. |
| `https://openthread.io/reference/config/group/config-logging#group__config-logging_1ga6c7b64ae7f0ab7741a2e340fcbe4f928 1` | Define to prepend the log level to all log messages. |
| `https://openthread.io/reference/config/group/config-logging#group__config-logging_1gaf2aee2ff5cd7c04a828d74c0d50c8641 0` | Define as 1 to prepend the current uptime to all log messages. |
| `https://openthread.io/reference/config/group/config-logging#group__config-logging_1ga9fafc2cd97577c0a45c6d5641dc31e53 1` | If defined as 1 when IPv6 message info is logged in mesh-forwarder, the source and destination IPv6 addresses of messages are also included. |
| `https://openthread.io/reference/config/group/config-logging#group__config-logging_1gacd0f5dc7876aa60798d7ad865f211796 ""` | Define suffix to append at the end of logs. |

## Macros

### OPENTHREAD_CONFIG_LOG_CLI

```
 OPENTHREAD_CONFIG_LOG_CLI 1
```
Define to enable CLI logging and `otLogCli()` OT function.

### OPENTHREAD_CONFIG_LOG_INSTANCE_AWARE_API_ENABLE

```
 OPENTHREAD_CONFIG_LOG_INSTANCE_AWARE_API_ENABLE 0
```
Define to 1 to enable the instance-aware platform logging API.

When this configuration is enabled, OpenThread logging will track the OpenThread instance (`otInstance`) from which a log is generated. The core will use the `otPlatLogOutput()` platform API instead of `otPlatLog()`. The new platform API provides the `otInstance` pointer along with the log as a fully formatted string, which is particularly useful in multi-instance setups to distinguish logs from different OpenThread instances.

### OPENTHREAD_CONFIG_LOG_LEVEL

```
 OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_CRIT
```
The log level (used at compile time).

If `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE` is set, this defines the most verbose log level possible. See `OPENTHREAD_CONFIG_LOG_LEVEL_INIT` to set the initial log level.

### OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE

```
 OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE 0
```
Define as 1 to enable dynamic log level control.

Note that the OPENTHREAD_CONFIG_LOG_LEVEL determines the log level at compile time. The dynamic log level control (if enabled) only allows decreasing the log level from the compile time value.

### OPENTHREAD_CONFIG_LOG_LEVEL_INIT

```
 OPENTHREAD_CONFIG_LOG_LEVEL_INIT OPENTHREAD_CONFIG_LOG_LEVEL
```
The initial log level used when OpenThread is initialized.

See `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE`.

### OPENTHREAD_CONFIG_LOG_LEVEL_OVERRIDE_ENABLE

```
 OPENTHREAD_CONFIG_LOG_LEVEL_OVERRIDE_ENABLE 0
```
Define to 1 to enable the log level override feature and its associated APIs.

This feature is used when `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE` is also enabled.

When enabled, new mechanism is added to allow temporary override of the current log level (e.g., to increase the level to capture more detailed information) and subsequently restore it to the original user-specified level.

### OPENTHREAD_CONFIG_LOG_MAX_SIZE

```
 OPENTHREAD_CONFIG_LOG_MAX_SIZE 150
```
The maximum log string size (number of chars).

### OPENTHREAD_CONFIG_LOG_OUTPUT

```
 OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED
```
Selects if, and where the LOG output goes to.

There are several options available

- [OPENTHREAD_CONFIG_LOG_OUTPUT_NONE](https://openthread.io/reference/config/group/config-logging#group__config-logging_1ga351a6d401ce5769a1903a643b4c56aad)   
- [OPENTHREAD_CONFIG_LOG_OUTPUT_DEBUG_UART](https://openthread.io/reference/config/group/config-logging#group__config-logging_1ga4ef5b0bc34ed833fc87e8ce2d71300df)   
- [OPENTHREAD_CONFIG_LOG_OUTPUT_APP](https://openthread.io/reference/config/group/config-logging#group__config-logging_1ga9995d202055365c787243821b14a3471)   
- [OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED](https://openthread.io/reference/config/group/config-logging#group__config-logging_1gad5b195689fe848bdaac28961778762ce)   
- and others

<br />

Note:

1) Because the default is: OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED The platform is expected to provide at least a stub for `otPlatLog()`.

2) This is effectively an ENUM so it can be if/else/endif at compile time.

### OPENTHREAD_CONFIG_LOG_OUTPUT_APP

```
 OPENTHREAD_CONFIG_LOG_OUTPUT_APP 2
```
Log output goes to the "application" provided otPlatLog() in NCP and CLI code.

### OPENTHREAD_CONFIG_LOG_OUTPUT_DEBUG_UART

```
 OPENTHREAD_CONFIG_LOG_OUTPUT_DEBUG_UART 1
```
Log output goes to the debug uart - requires OPENTHREAD_CONFIG_ENABLE_DEBUG_UART to be enabled.

### OPENTHREAD_CONFIG_LOG_OUTPUT_NONE

```
 OPENTHREAD_CONFIG_LOG_OUTPUT_NONE 0
```
Log output goes to the bit bucket (disabled)

### OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED

```
 OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED 3
```
Log output is handled by a platform defined function.

### OPENTHREAD_CONFIG_LOG_PKT_DUMP

```
 OPENTHREAD_CONFIG_LOG_PKT_DUMP 1
```
Define to enable dump logs (of packets).

### OPENTHREAD_CONFIG_LOG_PLATFORM

```
 OPENTHREAD_CONFIG_LOG_PLATFORM 1
```
Define to enable platform logging and `otLog{Level}Plat()` OT functions.

### OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL

```
 OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 1
```
Define to prepend the log level to all log messages.

### OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME

```
 OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME 0
```
Define as 1 to prepend the current uptime to all log messages.

### OPENTHREAD_CONFIG_LOG_SRC_DST_IP_ADDRESSES

```
 OPENTHREAD_CONFIG_LOG_SRC_DST_IP_ADDRESSES 1
```
If defined as 1 when IPv6 message info is logged in mesh-forwarder, the source and destination IPv6 addresses of messages are also included.

### OPENTHREAD_CONFIG_LOG_SUFFIX

```
 OPENTHREAD_CONFIG_LOG_SUFFIX ""
```
Define suffix to append at the end of logs.

## Resources

OpenThread API Reference topics originate from the source code, available
on [GitHub](https://github.com/openthread/openthread/tree/main/include/openthread).
For more information, or to contribute to our documentation, refer to
[Resources](https://openthread.io/resources).