Logging Module
Overview
Module that stores all log messages of your application as Mendix objects in the database, enabling you to view and search the log in the Mendix web client. Can be used in addition to the normal logging options (logging to file or the Mendix console) and has its own independent log level setting.
Documentation
Logging Module
Description
This module stores your application's log messages as Mendix objects in the database, allowing you to view and search logs directly in the Mendix web client.
It runs alongside your normal logging options (like server file or console logging) and has its own independent log level setting. It also features a scheduled event to clean up old messages, and a powerful PreFilter Rule Engine to strictly control what gets saved to the database.
Typical Usage Scenarios
- Giving application administrators access to logs directly from the Mendix interface.
- Quickly searching logs for specific errors without downloading or parsing text files.
- Filtering out noisy log messages (like specific node chatter or stack traces) before they ever reach the database to save space.
Features and Limitations
- Independent Configuration: Choose which log levels to record (e.g., INFO and higher) independently from your server's base logging.
- PreFilter Rule Engine: A flexible engine that evaluates incoming logs before they are saved. You can create rules to accept or drop messages based on regex matches against the log level, node, message text, or stack trace presence.
- Log Management: Admins can manually delete log messages.
- Automated Cleanup: The
CleanupDataLoggingscheduled event periodically removes old logs. Configure how many days to keep them using theLogHistoryDaysconstant. - Performance Note: Writing every log to the database can slow down your app. In a production environment, we highly recommend either logging only WARNING and higher, or heavily utilizing the PreFilter engine to drop unnecessary background noise.
PreFilter Rule Engine
The PreFilter intercepts every log message right before it gets saved. It runs the message through a prioritized list of rules to decide if it should be kept or thrown away.
How Evaluation Works (First-Match-Wins)
- Rules are evaluated in order of their
Prioritynumber, from lowest (0) to highest. - The engine checks the rule's regex pattern against your chosen log field.
- As soon as a rule matches, the engine applies the rule's
Action(either keep or discard) and immediately stops evaluating the rest of the rules. - If a log message doesn't match any active rules, the system keeps it by default.
Creating Rules When setting up a rule, you will configure the following fields:
- Action: Choose
ACCEPTto keep the log orDROPto discard it. - Target: Select which part of the log the regex should check:
Level,Node,Message, orHasStackTrace. - Regex: Write a standard Java regular expression to match the text (uses partial match logic).
- Priority: Use numbers (like 0, 1, 2) to sort the rules. Lower numbers run first.
- IsActive: A toggle to easily turn rules on or off.
Note: If a rule is marked inactive, is missing a required field, or has invalid regex syntax, the engine safely skips it without breaking your logging.
Dependencies
- Mendix 10.24 Environment
- No further dependencies
Installation & Configuration
- Microflows: In your project settings, set your After Startup and Before Shutdown microflows to point to
AfterStartup(in the Start folder) andBeforeShutdown(in the Stop folder) from the Logging module. - UI: Place the
Message_Overview_Contentsnippet somewhere in your app for users to view logs. - Roles: Assign the
Adminand/orReadOnlymodule roles. Both can view logs, but only Admins can delete them. - Base Log Level: Set the
Logging.Levelconstant to the desired value (defaults to INFO). - Automated Cleanup (Optional): Enable the
Logging.CleanupDataLoggingscheduled event and set theLogging.LogHistoryDaysconstant (defaults to -1, which means cleanup is disabled). - PreFilter Rules (Optional): Open the PreFilter configuration page in your Mendix app to set up your rule list. Ensure every rule you create has a valid Action, Target, and Priority.
Releases
Changelog: PreFilter Rule Engine Upgrade (v2)
We've completely overhauled the PreFilter engine. Instead of just checking a simple regex against a log message, it's now a full rule engine that gives you much more control over what logs to keep or throw away.
What's New
- Keep or Drop: You can now choose what happens when a rule matches. Use the new
Actionfield to eitherACCEPT(keep the log) orDROP(discard the log). - Target Specific Fields: Instead of only searching the main message text, you can now target specific parts of the log using the
Targetfield. You can search against theLevel,Node,Message, orHasStackTrace. - Rule Priorities: You can now control the exact order in which rules run using the
Prioritynumber. The engine looks at rules starting from the lowest number (e.g., 0 is evaluated first). - First Match Wins: The engine stops evaluating as soon as it finds the first matching rule and applies that action.
- Turn Rules On/Off: We added an
IsActivetoggle. This lets you disable rules temporarily without having to delete them entirely. - Better Error Handling: If you make a typo in your regex syntax, it won't break the whole system. The engine will just skip that broken rule and log a warning.
What You Need to Know (Breaking Changes & Migration)
- Update Your Old Rules: All your existing rules in the database need to be updated with the new fields. If you leave these new fields empty, the engine will completely ignore the rules.
- How to Keep the Old Behavior: To make your existing rules work exactly like they used to, set their
ActiontoDROP,TargettoMessage,Priorityto0, andIsActivetotrue. - Default Behavior: If a log message doesn't match any of your active rules, it will be allowed through.
- Unpublish version 2.2.0; We found a bug on that version
- Update dependencies to latest version
- Set minimum version to 10.24.0