# Log

## `log` Function

The `this.log()` function provides a way to **output debug information** from within **server-side variables** in JENTIS. Since `console.log()` is **not supported** in this environment, `this.log()` is your go-to method for debugging logic and inspecting values during execution.

***

### Purpose

Use `this.log()` to:

* Debug the behavior of your server-side variables
* Log the state of intermediate values or conditions
* Trace why a variable returns a specific result
* Monitor runtime outputs inside the **JENTIS Preview/Debug Monitor**

***

### Function Definition

| Property          | Description              |
| ----------------- | ------------------------ |
| **Function Name** | `this.log`               |
| **Type**          | `function`               |
| **Available In**  | Server-Side Variables    |
| **Returns**       | `void` (no return value) |

***

### Parameters

| Parameter | Description                               | Type  | Required                                      | Example           |
| --------- | ----------------------------------------- | ----- | --------------------------------------------- | ----------------- |
| `value`   | Any value (string, number, object, array) | `any` | <i class="fa-square-check">:square-check:</i> | `"Debug message"` |

***

### Example Usage

```js
async function() {
    const gclid = this.getFrontendVariable("gclid");
    this.log("Extracted GCLID: " + gclid); // Will show up in the debug monitor
    return gclid;
}
```

You can also log objects and arrays:

```js
this.log({ status: "ok", data: [1, 2, 3] });
```

***

### Where to View Logs

Logs created via `this.log()` will appear:

* In the **Preview Mode** of the JENTIS Tag Manager
* Under the **"Variables" tab** for the executed tracking event
* Associated with the **server-side variable** that made the log call

This provides visibility into the **variable’s internal logic**, even if the value doesn't return as expected.

***

### Use Cases

* Debug conditional branches
* Log HTTP response payloads
* Check whether values from `this.getFrontendVariable()`, `this.userStorage.read()`, etc., are being resolved correctly
* Understand the flow of asynchronous logic

***

### Notes

* This is a **debug-only tool** — logs are visible only in preview/debug mode.
* Does **not** output to the browser console or persist in production logs.
* Avoid logging sensitive information (e.g., personal identifiers) even in debug mode.

***

### Summary

`this.log()` is the official way to debug and trace the behavior of your server-side variables in JENTIS. It helps you inspect values in real-time during preview mode, making troubleshooting and development faster, safer, and more transparent.
