9.2 Logging, Error Tracking & Monitoring
Key Takeaways
- The `Log message` activity records diagnostic, operational, and audit information using six standardized severity levels: Trace, Debug, Info, Warning, Error, and Critical.
- Log level filtering operates hierarchically: setting a log node to a specific threshold outputs all messages at or above that severity while discarding lower-severity records.
- Custom log nodes must represent architectural components, integration boundaries, or functional modules rather than dynamic runtime strings to avoid polluting the runtime log node registry.
- Log levels can be reconfigured dynamically at runtime in the Mendix Cloud Developer Portal without restarting or redeploying the application container.
9.2 Logging, Error Tracking & Monitoring
Exam Focus: Enterprise applications require continuous operational visibility. The Mendix Certified Intermediate Developer exam tests your ability to design robust logging strategies using the
Log messageactivity, categorize events across the six official log levels, establish structured naming conventions for custom log nodes, adjust log levels dynamically at runtime in the Mendix Cloud Console without redeploying, and capture complete exception details via$latestError.
Logging is the primary mechanism for auditing system health, tracking asynchronous processes, and diagnosing runtime anomalies in production environments where interactive debuggers cannot be attached. A well-designed logging architecture balances diagnostic granularity against system performance, disk storage, and data privacy.
The Mendix Logging Framework & Log Message Activity
The Mendix Runtime features a high-performance, asynchronous logging pipeline built on industry-standard logging libraries. In microflows, developers emit log events using the Log message activity.
Anatomy of the Log message Activity
Configuring a Log message activity in Studio Pro requires four fundamental properties:
- Log Node: A string expression or literal that defines the logical subsystem or category emitting the log (e.g.,
'Billing.StripeGateway'). - Log Level: The severity classification assigned to the message (Trace, Debug, Info, Warning, Error, or Critical).
- Message: A string expression constructing the message body. Expressions can concatenate static text with runtime variables (e.g.,
'Failed to process order ' + $Order/OrderNumber + ' for customer ' + $Customer/FullName). - Include latest error: A boolean checkbox. When checked, the runtime automatically appends the exception message, Java class name, and full server stack trace from the internal
$latestErrorvariable to the log output.
[Error Handler Triggered] ──> [Log message: Error Level, Node: 'ERP_Sync', Include Latest Error: True] ──> [Custom Rollback]
The Six Hierarchical Log Levels
Mendix defines six standardized log levels organized in a strict hierarchy of increasing severity. Understanding the operational purpose of each level is critical for exam certification and operational governance:
1. Trace (Most Verbose)
- Purpose: Extremely fine-grained diagnostic tracing. Used for inspecting raw payload strings (e.g., complete JSON/XML integration payloads), loop iteration counters, and low-level internal state transitions.
- Production Status: Disabled. Trace generates immense I/O and disk bloat; it should only be enabled temporarily in non-production or for isolated triage sessions.
2. Debug
- Purpose: Detailed diagnostic information useful during active development and quality assurance testing. Records function entry/exit, parameter values, and branch evaluation results.
- Production Status: Disabled. Leaving Debug enabled in production degrades runtime throughput and consumes gigabytes of log storage.
3. Info
- Purpose: High-level operational events that confirm normal application functioning. Examples include application startup completion, scheduled event execution summaries (e.g., "Nightly billing batch completed: 450 invoices processed"), and external service connection initializations.
- Production Status: Standard / Selective. Used for major lifecycle milestones.
4. Warning
- Purpose: Unexpected runtime events or anomalies that do not stop the current transaction or disrupt user experience, but indicate potential degradation or future failure. Examples include invoking a deprecated REST API, transient connection retry successes, fallback cache usage, or approaching resource thresholds.
- Production Status: Enabled by default.
5. Error
- Purpose: Severe functional failures that halt a specific transaction, user request, or background job, but do not crash the entire application container. Examples include unhandled exceptions caught by an error handling flow, payment gateway rejection, or database validation rule violations.
- Production Status: Enabled by default. Generates alerts in monitoring dashboards.
6. Critical (Highest Severity)
- Purpose: Catastrophic system failures that threaten application integrity, corrupt data, or render core subsystems completely unavailable. Examples include database connection pool exhaustion, file system disk full errors, missing encryption keys, or unrecoverable infrastructure crashes.
- Production Status: Always Enabled. Triggers high-priority operational paging (SMS, email, PagerDuty).
| Log Level | Numeric Severity | Production Default | Typical Information Logged |
|---|---|---|---|
| Trace | 1 (Lowest) | Off | Raw XML/JSON payloads, loop index counters, sub-expression results |
| Debug | 2 | Off | Microflow parameter values, decision split branch choices |
| Info | 3 | Selective | Batch job completion, server startup, scheduled event triggers |
| Warning | 4 | On | Non-critical API timeouts, retry attempts, deprecation notices |
| Error | 5 | On | Transaction rollbacks, failed REST calls, caught exceptions |
| Critical | 6 (Highest) | On | Database pool exhaustion, out-of-memory warnings, license expiry |
The Severity Filtering Principle
Log nodes filter messages mathematically based on the active runtime threshold:
A message is written only when its severity is greater than or equal to the threshold configured on its log node.
If a log node is configured at the Warning level:
- Messages submitted as Warning, Error, and Critical are written to the log file.
- Messages submitted as Info, Debug, and Trace are silently discarded at zero I/O cost.
Log Nodes: Architectural Categorization & Best Practices
A Log Node is a string identifier that categorizes log messages by functional area or technical component. Rather than funneling all application output into a generic bucket, log nodes allow administrators to control logging granularity per subsystem.
Standard System Log Nodes
The Mendix Runtime provides built-in system nodes:
Core: Runtime engine lifecycle, domain model loading, session management.ConnectionBus: Database queries, SQL generation, connection pool management, and schema migrations.ActionManager: Microflow and Java action dispatching and execution lifecycle.WebUI: Client-to-server communication, widget rendering requests, and web client sessions.RestServices: Inbound and outbound REST integration request and response lifecycles.
Custom Log Node Naming Standards
When creating custom log nodes in your application modules, follow a strict, dot-delimited hierarchy:
ModuleName.SubsystemName— for example'Sales.PaymentGateway'or'Warehouse.SAPConnector'
The Dynamic Log Node Name Anti-Pattern
Exam Trap: A frequent mistake made by novice developers is constructing dynamic log node names using runtime entity values, such as:
// CATASTROPHIC ANTI-PATTERN: 'User_' + $Account/Name 'Order_' + $Order/OrderNumberWhy this is disastrous: In the Mendix Runtime, every unique log node name is registered in an internal concurrent hash table and synchronized across memory. Creating dynamic log node names causes:
- Memory Leaks: Thousands of ephemeral node objects accumulate in Java heap memory and can never be garbage collected.
- Portal Interface Pollution: In the Mendix Cloud Developer Portal, the log configuration interface renders a dropdown list of all registered nodes. Generating tens of thousands of dynamic nodes renders the administrative UI completely unusable.
- Impossibility of Filtering: Administrators cannot configure log levels for individual orders or dynamic users.
Correct Architecture: Keep the log node static (e.g.,
'Sales.OrderProcessing') and include the dynamic identifiers ($OrderNumber, $AccountName) in the message text.
Dynamic Runtime Log Configuration in Mendix Cloud
One of the most powerful enterprise capabilities of the Mendix platform is the ability to reconfigure logging thresholds on the fly without downtime.
Adjusting Log Levels in the Developer Portal
In the Mendix Developer Portal / Mendix Cloud Console:
- Navigate to Environments and select the target deployment (e.g., Acceptance or Production).
- Open the Runtime Settings / Log Levels tab.
- The console displays all registered log nodes alongside their active thresholds.
- Change the dropdown threshold for a specific node (for example, setting
'Billing.StripeGateway'fromWarningdown toDebug). - Save the setting.
The Zero-Downtime Rule
Changing log levels in the Mendix Cloud takes effect immediately across all running runtime containers. It does not require:
- Restarting the application container.
- Rebuilding or deploying a new package.
- Interrupting active user sessions or scheduled tasks.
Once an operational defect has been diagnosed and captured, the developer must immediately restore the node back to its production baseline (Warning or Info) to protect storage and throughput.
Error Tracking, Stack Traces & Data Privacy Compliance
Leveraging $latestError in Custom Error Handlers
When a microflow activity configured with Custom with Rollback or Custom without Rollback error handling fails, the Mendix Runtime instantiates an internal $latestError variable accessible within the error handling branch. The variable contains three essential attributes:
$latestError/Message: A high-level description of the failure.$latestError/ErrorType: The technical category or Java exception class name.$latestError/Stacktrace: The complete server-side Java execution trace showing the exact line of code or activity where the exception occurred.
Always check Include latest error on the Log message activity in your error handling sub-flows to guarantee that this stack trace is preserved in the runtime log.
Data Privacy & Sensitive Information Masking
Modern regulatory frameworks—including GDPR, HIPAA, and PCI-DSS—strictly prohibit logging sensitive personal data. Developers must sanitize log messages:
- Never Log Plaintext Credentials: Passwords, API authorization tokens, bearer tokens, or secret keys.
- Redact Financial Identifiers: Credit card primary account numbers (PAN), bank account IBANs, and CVV codes.
- Mask Personally Identifiable Information (PII): National identity numbers (SSNs), patient medical records, and personal phone numbers.
Cloud Monitoring, Metrics & Automated Alerting
Logging is complemented by infrastructure metrics and automated alerts in the Mendix Cloud:
- JVM Heap Memory: Tracks used memory vs. committed memory to identify object retention leaks.
- Database Connection Pool: Monitors active connections vs. max connections to detect unclosed transactions or connection starvation.
- CPU & Disk Storage: Monitors container compute loads and prevents log files from filling local disk volumes.
- Automated Alerts: Administrators configure notification policies that send automated emails, webhooks, or PagerDuty alerts whenever
CriticalorErrorfrequency exceeds configured thresholds (e.g., more than 5 errors in 60 seconds). - Log Streaming / Log Drains: Enterprise Mendix deployments can stream logs in real time over TLS/Syslog to centralized SIEM platforms such as Datadog, Splunk, Dynatrace, or Elasticsearch.
A custom log node named 'Integration.SAP' is configured at the Warning log level in the Mendix Cloud runtime. Which messages will be written to the log file?
What is the primary architectural flaw of using dynamic expressions like 'UserSync_' + $Account/Email as a Log Node name in a microflow Log message activity?
How can an operations engineer adjust the log level of a custom log node from Info to Trace in a running Mendix Cloud Acceptance environment?