> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# onConsoleLog

- **Type:** `(content: string, type: 'stdout' | 'stderr') => boolean | void`
- **Default:** `undefined`

Custom handler for console log in tests, which is helpful for filtering out logs from third-party libraries.

The handler receives the log `content` along with its `type` (`'stdout'` or `'stderr'`), so you can filter by stream as well as by text. If you return `false`, Rstest will not print the log to the console.

```ts title="rstest.config.ts"
import { defineConfig } from '@rstest/core';

export default defineConfig({
  onConsoleLog: (content, type) => {
    if (type === 'stderr' && content.includes('deprecated')) {
      return false;
    }
  },
});
```

:::note
When [disableConsoleIntercept](/config/test/disable-console-intercept.md) is set to `true`, `onConsoleLog` will not take effect.
:::

## Silencing console logs

You can silence console logs by returning `false` in the `onConsoleLog` handler.

```ts title="rstest.config.ts"
import { defineConfig } from '@rstest/core';
export default defineConfig({
  onConsoleLog: () => false,
});
```
