Creating Application Logs

Last updated on June 26, 2024.

This guide shows you how to create logs using the Liquid tag. This tag lets you print any information to application logs as type info, debug, error, or a type you specify and list them in your console next to your sync.

You can use the tag in any file that accepts Liquid so that you can use them in Pages, Layouts, Partials, Permissions, async callbacks, etc.

Prerequisites

To follow the steps in this tutorial, you must have the installed, an environment configured, and the codebase set up. You must also understand concepts such as Pages, Templates, and the technologies behind Insites, particularly Liquid and GraphQL.

Steps

Creating application logs is a two-step process:

  • Step 1: Using the 'log' Liquid tag
  • Step 2: Starting the code logging process

Step 1: Using the 'log' Liquid tag

Create a page using the Liquid tag, and sync it.

app/views/pages/log-test.liquid

Notes

  • You can print any object to the logs.
  • You can use parameters (e.g. take parameters from the URL and include them in the message).
  • The log entry  can be any string you want to use to tag your entry.
  • If you chose , insites-cli marks it red and tries to notify your operating system (OS).

Step 2: Starting the code logging process

In your command line, enter the command to start live logging:

This command pulls the logs from the server every few seconds and displays them in your command line.

Example

The system also logs a path that triggers a particular log entry. This way, you can find the cause of the error more easily.

Have a suggestion for this page?

Didn't quite find what you are looking for or have feedback on how we can make the content better then we would love to hear from you. Please provide us feedback and we will get back to you shortly.