# logMessages

Source: https://sdk.pdf.net/docs/v1/reference/logMessages



Delivers everything the SDK logs: problems it worked around without failing the operation. The SDK never prints to the browser console; subscribe to receive the messages. See [Error handling and logging](https://sdk.pdf.net/docs/v1/guides/error-handling-and-logging) for the throw-versus-log rules.

```ts
const unsubscribe = logMessages.on('message', (logMessage) => { ... })
```

Each `LogMessage` carries:

| Field     | Meaning                                                                                                                                                                            |
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `level`   | The severity: `LogLevel.Debug`, `Info`, `Warning`, or `Error`. The values are numeric and ordered, so a threshold is a comparison.                                                 |
| `reason`  | The problem category: a `LogReason` member (see below).                                                                                                                            |
| `message` | A static string. Variable details never appear in it, so messages group cleanly in log aggregation. A `License` message is the exception: its text comes from the license service. |
| `data`    | The variable details, when any.                                                                                                                                                    |
| `stack`   | The call stack at the point the message was emitted, when available.                                                                                                               |

## Reasons [#reasons]

| `LogReason`           | Level     | Meaning                                                                                                                     |
| --------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------- |
| `DocumentFormatIssue` | `Info`    | The PDF content breaks the PDF specification; the SDK handled it.                                                           |
| `NotSupported`        | `Warning` | The document uses a PDF feature the SDK doesn't support yet.                                                                |
| `PerformanceIssue`    | `Warning` | Something works correctly but wastefully and is worth investigating.                                                        |
| `InvalidInput`        | `Error`   | Your code passed input the SDK couldn't use, such as an incompatible combination of arguments.                              |
| `UnexpectedError`     | `Error`   | An internal error unrelated to the document content.                                                                        |
| `License`             | Any       | A notice from the license service, such as an exceeded quota, reported after a document opens. The service picks the level. |

## Example [#example]

```tsx
import { logMessages, LogLevel } from '@sdk-pdf/react'

const unsubscribe = logMessages.on('message', (logMessage) => {
  if (logMessage.level >= LogLevel.Warning) {
    reportToMonitoring(logMessage.message, logMessage.data)
  }
})
```

