> For the complete documentation index, see [llms.txt](https://docs.rulecube.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rulecube.com/v2.5/how-to-guides/ruleset-development/debugging-your-ruleset.md).

# Debugging your Ruleset

You may find yourself in a situation where you need to debug some complex logic in your code.

When you're familiar with programming in JavaScript, you'll no doubt know about `console.log`.

Rulecube offers a similar API! You can use `console.log()`, `console.warn()` and `console.error()` anywhere in your Ruleset code.

#### Example

<figure><img src="/files/EDpDuMI8Gn8Ks9k0mnBW" alt=""><figcaption></figcaption></figure>

#### Sandbox

The Sandbox offers a visualization of your Console logging below the actual result after executing.

<figure><img src="/files/ljs0W7ThUTDgAhk15XFg" alt=""><figcaption></figcaption></figure>

#### What happens to my logs?

Your logs are returned in the execution result of the API. They are not stored on any server. The amount of log lines is also capped at a certain limit. The default is a maximum of 100 lines. This means only the last 100 lines are returned.

#### API call

By default, no logging is returned in the ruleset execution result. This can be changed by setting the execution `options.logLevel` to 'info', 'warning' or 'error'. See a Ruleset's Swagger UI page for more info (at the bottom of its Version settings).

* 'info' - every log will be returned
* 'warning' - only warnings and errors (console.warn() and console.error())
* 'error' - only errors (console.error())

The API result from an execute will contain your logging in the `diagnostics` property. This is an array with the following object structure:

| Field     | Type     | Description                                                                  |
| --------- | -------- | ---------------------------------------------------------------------------- |
| t         | `number` | Timestamp represented as number of milliseconds after 1970-01-01             |
| type      | `string` | "log", "warn" or "error"                                                     |
| arguments | `any[]`  | An array of the parameters you passed to console.log() / .warn() or .error() |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rulecube.com/v2.5/how-to-guides/ruleset-development/debugging-your-ruleset.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
