Tutorial | Generate Logs to Debug a Site

This tutorial demonstrates how to generate and view logs from site code. The logs are viewed using Wix Logs.

In this tutorial, you'll:

  1. Add a button to a site
  2. Generate and view a log

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 a site

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

  1. Add a button labeled button1 to a site's home page. Here's how it should look:

    Button added to site home page

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

    Note: This tutorial uses the $w() selector for frontend element interaction, which is a Velo API that remains necessary for frontend code even when using the JavaScript SDK for backend development.

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

    Copy
  3. Preview or publish the site.

    Note: You can generate logs when previewing a site, but some log information is available only when the 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.

    Wix Logs window

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

    The logs appear in the Wix Logs page:

    Wix Logs error example

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

    Wix Logs log details

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

See also

Did this help?