---
title: "Set Trace"
description: "The trace settings of the running product can be shown and changed from a script, such as around one step under investigation."
language: en
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/en/docs/invantive-script/statements/set-trace
original: https://documentation.invantive.eu/en/docs/invantive-script/statements/set-trace
updated: 2026-11-10T00:00:00Z
license: https://documentation.invantive.eu/en/
---

## Syntax
The trace settings of the running product can be shown and changed from a script using the syntax:
```
local trace
local trace on
local trace off
local trace to file on
local trace to file on folder "FOLDER"
local trace to file off
```
Available from release 27.0. The statement needs the right `itgen_trace`.

`local trace` on its own shows the settings in effect with message itgentsm008: whether trace is active, whether the trace is also written to a file, the trace folder and the trace file which is written now.

`local trace on` and `local trace off` switch the trace. `local trace to file on` writes the trace to a file in the trace folder and switches trace on as well; with `folder` the trace files go to the folder named, which has to be a full path. `local trace to file off` completes and closes the trace file and leaves trace on. `local trace off` closes the trace file as well.

A change is in effect at once and lasts until the product closes; it is not kept for the next start. A folder which is not a full path is refused with itgentsm001, and a folder which can not be made or written is refused as well; in both cases the trace continues as it was. Variables such as `${NAME}` in the folder are replaced first. See [[Trace Settings]] for the other ways to set the trace, and [[Trace Files]] for what a trace file holds.

## Examples
The following example shows the trace settings in effect:
```
local trace
```
The following example traces one step of a job to a file in the default trace folder and closes the file afterwards:
```
local trace to file on

select count(*) from Payroll.Employees

local trace off
```
The following example writes the trace files of the rest of the script to a folder of its own:
```
local define TRACE_FOLDER "c:\jobs\trace"

local trace to file on folder "${TRACE_FOLDER}"
```