If you would like to upgrade to a newer long-term support version of Studio Pro, see Moving from Mendix Studio Pro 8 to 9.

Set Log Levels

Last modified: September 19, 2024

Introduction

Each application has a log to which it writes log messages to monitor the health of the running application. Log levels are used to label the log messages and to highlight the highest priority ones so that they can be easily identified and responded to.

This how-to teaches you how to do the following:

  • Configure the log levels for the various types of logging within your app

Logging Basics

Log Messages

Log messages appear in the log of your Mendix application and present contextualized and detailed information, including the following:

  • Date and time the log message was created
  • Level
  • Log node
  • Message
  • Stack trace

Log Node

The log node describes the source of the log message. For example, in a log message from the email module, the log node could be set to Email Module.

Message

Most messages in the log are auto-generated by the system (for example, Mendix Runtime successfully started, the application is now available). However, log messages that are created via a microflow, can be customized by the developer.

Customized log messages are created by defining a Template. The template is the structure of the message, and can be composed of parameters and free text.

In the image above, the template for the message is Email not sent to customer {1}. With this example template, when the error occurs the customer’s email address is inserted into the parameter placeholder {1} (for example, the log message would be Email not sent to customer john.smith@hiscompany.com). Thus, the log message is customized with data that is specific to the error.

Stack Trace

The stack trace is a list of current method calls from the point when the application was started to the point where the exception occurred.

In Studio Pro, log messages that include a stack trace are marked with a paperclip icon. Double-clicking this icon shows the stack trace.

Level

The log level defines the severity of the log message. In Studio Pro, this is represented by different colors and an icon.

These are the log levels used by Mendix:

Level Icon Color Description
Trace More detailed information. These are only written to logs.
Debug Detailed information, typically of interest only when diagnosing problems.
Info Confirmation that things are working as expected.
Warning
Orange Indicates that something unexpected happened or that there is some problem in the near future (for example, “disk space low”). The application is still working as expected.
Error
Red Due to a more serious problem, the application has not been able to perform some function.
Critical
White (text), red (background) A serious error has occurred, indicating that the application itself may be unable to continue running.

Setting the Log Levels

In this section, you will learn how to configure the log levels of the messages produced by the system. The different highlighted levels can be applied to the predefined logging produced by Mendix Studio Pro and to custom logging.

This section describes how to configure both the log levels for predefined logging created by Studio Pro and custom logging.

Configuring Log Levels via Script

Log levels can be configured through the runtime admin port before the actual log levels exist. This enables creating a script that sets all the required log levels at once.

This is a Python script that sets ConnectionBus and ActionManager to the Trace and Debug levels:

import requests, base64, json, sys

payload = {
    'action':'set_log_level',
    'params': {'nodes' : [
        { 'name':'ConnectionBus', 'level':'TRACE'},
        { 'name':'ActionManager', 'level':'DEBUG'}
        ], 'force':True}
}

You can run this script as follows:

C:\temp\LogDemoApp\python
λ python setlogs.py 87a32a3e-c6db-4bc8-9fa3-7cd5b108eaec 8090
{"feedback":{},"result":0}

Configuring the Log Levels for Standard Log Messages

To set the log levels for standard log messages, follow these steps:

  1. In the Console pane, click Advanced to open the menu of advanced options.
  2. Click Set log levels.
  3. For the relevant Log node, select the desired level from the drop-down in the Log level column.

Configuring the Log Levels for Custom Log Messages

To set the level of custom log messages that you have created via a microflow, follow these steps:

  1. Open the microflow in which you intend to change the log message level.
  2. Double-click the log message activity.
  3. In the Log level drop-down, select the desired level.

Read More