> ## Documentation Index
> Fetch the complete documentation index at: https://tbd-6fc993ce-mintlify-add-deploy-button-docs-27400.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Logs

## Via API

After you [invoke](/apps/invoke) an action, you can stream the invocation's logs in real time:

<CodeGroup>
  ```typescript Typescript/Javascript theme={null}
  import Kernel from '@onkernel/sdk';

  const kernel = new Kernel();

  const logs = await kernel.invocations.follow(invocation_id);
  ```

  ```python Python theme={null}
  from kernel import Kernel

  kernel = Kernel()
  logs = kernel.invocations.follow(invocation_id)
  ```
</CodeGroup>

<Info>Log lines will be truncated to 64KiB. For large payloads write data to external storage and log a reference instead.</Info>

### Example

Here's an example showing how to handle streaming logs:

```typescript Typescript/Javascript theme={null}
const follow = await kernel.invocations.follow(invocation.id);

for await (const evt of follow) {
  if (evt.event === 'log') {
    console.log(`[${evt.timestamp}] ${evt.message}`);
  } else if (evt.event === 'error') {
    console.error('Error:', evt.error.message);
    break;
  } else if (evt.event === 'invocation_state') {
    if (evt.invocation.status === 'succeeded' || evt.invocation.status === 'failed') {
      break;
    }
  }
}
```

## Via CLI

You can also stream the logs to your terminal via the CLI:

```bash theme={null}
kernel logs <app_name> --follow
```

If you don't specify `--follow`, the logs will print to the terminal until 3 seconds of inactivity and then stops.

You can get logs for a specific invocation by adding:

```
-i --invocation <invocation id>    Show logs for a specific invocation of the app.
```
