# Logging

{% hint style="warning" %}

#### Workshop - Logging

Use logging to diagnose transformation problems. Create a controlled type mismatch error. Use log level and output to find the cause.

**What you’ll do**

* Change field metadata to trigger an error
* Run with **Basic** and **Row level** logging
* Use **Execution results** to find the failing step
* Locate the same error in `pdi.log`

**Prerequisites:** Complete the **Hello World** workshop

**Estimated time:** 5 minutes
{% endhint %}

{% embed url="<https://www.loom.com/share/868c1e73bdeb464e9ef5c2dd3c220d61?hideEmbedTopBar=true&hide_owner=true&hide_share=true&hide_title=true>" %}
Logging
{% endembed %}

***

{% hint style="info" %}
**Create a new transformation**

Use any of these options to open a new transformation tab:

* Select **File** > **New** > **Transformation**
* Use `Ctrl+N` (Windows/Linux) or `Cmd+N` (macOS)
  {% endhint %}

<figure><img src="https://3680356391-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZpCSy6Skj215f4oWypdc%2Fuploads%2Fgit-blob-084fd579269b0cfeb95241c505ba6e67962e8f21%2Fhello%20world.tr.png?alt=media" alt="" width="375"><figcaption><p>Logging</p></figcaption></figure>

{% file src="<https://3680356391-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZpCSy6Skj215f4oWypdc%2Fuploads%2FvbNhfByjuU5ihEZNULmt%2Ftr_hello_world.ktr?alt=media&token=66fb6fed-d009-49d1-9c61-0c06d7f98a50>" %}

{% tabs %}
{% tab title="1. Modify Generate Rows" %}
{% hint style="info" %}
Start from the transformation you built in **Hello World**.
{% endhint %}

{% hint style="info" %}

#### **Generate Rows**

Generate Rows is a test-data step. It is a quick way to validate logging and error handling.
{% endhint %}

{% hint style="warning" %}
To create an error, change the field type for `message` from **String** to **Integer**.
{% endhint %}

1. Double-click the **Generate Rows** step.
2. Change the type for `message` to **Integer**.

<div align="center"><figure><img src="https://3680356391-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZpCSy6Skj215f4oWypdc%2Fuploads%2Fgit-blob-a918c5f15aa008762be0de711cdfdcafe3f80a2d%2Fchange%20to%20integer.png?alt=media" alt="" width="375"><figcaption><p>Change data type</p></figcaption></figure></div>

3. Select **OK**.
   {% endtab %}

{% tab title="2. Run" %}
{% hint style="info" %}

#### Run the transformation

Run with a higher log level to see row-level detail.
{% endhint %}

1. Select **Run** in the canvas toolbar.
2. Set **Log level** to **Basic**.
3. Select **Run**.
4. Run again with **Log level** set to **Row level**.

<div align="center"><figure><img src="https://3680356391-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZpCSy6Skj215f4oWypdc%2Fuploads%2Fgit-blob-3e818248fddf4c8acb4787791fc4090885713dfe%2Flog%20-%20row%20level.png?alt=media" alt="" width="563"><figcaption><p>Set row level debugging</p></figcaption></figure></div>

5. Select **Run**. The failing step is highlighted.

<figure><img src="https://3680356391-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZpCSy6Skj215f4oWypdc%2Fuploads%2Fgit-blob-fe81732737a4e65880ec8df0343eaea084288541%2Flog%20-%20step.png?alt=media" alt="" width="375"><figcaption><p>Error in step</p></figcaption></figure>

6. In **Execution results**, open the **Log** tab.

<figure><img src="https://3680356391-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZpCSy6Skj215f4oWypdc%2Fuploads%2Fgit-blob-f97869a2e3a9886f6ab872d1b544aa5e94775363%2Flog%20error.png?alt=media" alt=""><figcaption><p>Logging - error</p></figcaption></figure>

The error text is in the log output. Look for the first **ERROR** entry.

{% hint style="info" %}
Tip: Select the minus icon to show errors only.

The same error is written to `pdi.log`:

{% tabs %}
{% tab title="Windows" %}
`C:\\Pentaho\\design-tools\\data-integration\\logs\\pdi.log`
{% endtab %}

{% tab title="macOS / Linux" %}
`~/Pentaho/design-tools/data-integration/logs/pdi.log`
{% endtab %}
{% endtabs %}
{% endhint %}

<figure><img src="https://3680356391-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZpCSy6Skj215f4oWypdc%2Fuploads%2Fgit-blob-d568ff9c2d22880892ebbdb86a462e766e2e4717%2Fimage.png?alt=media" alt=""><figcaption><p>pdi.log - Linux</p></figcaption></figure>
{% endtab %}
{% endtabs %}

***

Next workshop: [Error Handling](https://academy.pentaho.com/pentaho-data-integration/data-integration/concepts-and-terminology/error-handling)
