---
editLink: false
lastUpdated: false
---

[@salesforce/b2c-tooling-sdk](../../../modules.md) / [operations/logs](../index.md) / watchLogs

# Function: watchLogs()

> **watchLogs**(`instance`, `options`): `Promise`\<[`LogWatch`](../interfaces/LogWatch.md)\>

Defined in: [packages/b2c-tooling-sdk/src/operations/logs/watch.ts:74](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/d7ff38c7ca2b1411cd718b9554500c9416f00266/packages/b2c-tooling-sdk/src/operations/logs/watch.ts#L74)

Start a buffered log watch. Entries matching `level`/`search` are buffered up
to the caps, oldest dropped first; `poll()` reports how many were dropped.

## Parameters

### instance

[`B2CInstance`](../../../instance/classes/B2CInstance.md)

### options

[`WatchLogsOptions`](../interfaces/WatchLogsOptions.md) = `{}`

## Returns

`Promise`\<[`LogWatch`](../interfaces/LogWatch.md)\>

## Example

```typescript
const watch = await watchLogs(instance, {prefixes: ['error'], level: ['ERROR']});
const {entries, truncated} = await watch.poll({timeoutMs: 5000});
await watch.stop();
```
