Tutorial | Generate Logs to Debug a Site

This tutorial demonstrates how to generate logs from site code. We will then view the generated logs using Wix Logs.

In this tutorial, we will:

  1. Add a button to a site's home page.
  2. Create an event handler that generates a log whenever the button is clicked.
  3. View the generated log using Wix Logs.

Note: In this tutorial, logs are generated from page code. However, you can also generate logs from backend code.

Step 1 | Add a button to your site

Add a button to your site and create an event handler:

  1. Add a button labeled button1 to your site's home page, like this:

  2. In the site's home page code, add an event handler that runs whenever the button is clicked.

    For the purposes of this tutorial, let's produce an error by defining factor3 instead of factor2.

    Copy
  3. Preview or publish your site.

    Note: You can generate logs when previewing your site, but some log information is available only when your site is published.

Step 2 | Generate and view a log

Generate a log and view it using Wix Logs as follows:

  1. In a separate browser tab or window, open the Wix Logs page.

  2. In your live site's home page or in Preview mode, click the button you created.

    The logs appear in the Wix Logs page:

  3. Click View for the log with the error to see its full details on the right:

    Check out the jsonPayload to see an explanation for the error.

See also

Did this help?