Turning on Debug Logging
Mango uses Apache Log4j2 for its logging framework. By default, Mango logs at the info level, which captures normal operational events. When troubleshooting specific subsystems, you can enable debug or trace level logging by providing a custom log4j2.xml configuration file.
Three Steps to Start Debugging
Step 1: Download the Log4j2 Configuration File
Open a terminal and navigate to your Mango data directory, then download the default log4j2.xml template.
Linux and Mac:
cd MA_HOME
wget https://docs-v5.radixiot.com/assets/files/5.0.x/log4j2.xml
Windows:
cd MA_HOME
curl -O https://docs-v5.radixiot.com/assets/files/5.0.x/log4j2.xml
Step 2: Add Debug Loggers
Open log4j2.xml and insert <AsyncLogger> entries between the <Loggers> tags for the subsystems you want to debug. Examples are provided below for common modules.
Step 3: Enable the Custom Configuration
Open your mango.properties file and set:
log4j2.configurationFile=log4j2.xml
The path is relative to your data directory (paths.data). You may also provide an absolute path. Restart Mango for the changes to take effect.
Module-Specific Debug Loggers
BACnet
<AsyncLogger includeLocation="true" name="com.serotonin.bacnet4j" level="debug"/>
<AsyncLogger includeLocation="true" name="com.serotonin.ma.bacnet" level="debug"/>
SNMP
<AsyncLogger includeLocation="true" name="com.serotonin.m2m2.snmp" level="debug"/>
<AsyncLogger includeLocation="true" name="org.snmp4j" level="debug"/>
Haystack
<AsyncLogger includeLocation="true" name="com.infiniteautomation.mango.haystack" level="debug"/>
<AsyncLogger includeLocation="true" name="org.projecthaystack" level="debug"/>
Suppress Poll Aborted Logs
If data source poll-aborted messages are filling your logs, you can suppress them:
<AsyncLogger includeLocation="true" name="com.serotonin.m2m2.rt.dataSource.PollingDataSource" level="error"/>
Log4j2 Log Levels
| Level | Description |
|---|---|
trace | Finest-grain logging. Produces very large log files; use sparingly. |
debug | Detailed diagnostic output. Use the most specific category possible to limit log volume. |
info | Default level for most Mango subsystems. Normal operational messages. |
warn | Warning conditions that may require attention but do not prevent operation. |
error | Error conditions that indicate a failure in a specific operation. |
fatal | Critical failures that typically prevent Mango from continuing. |
Log4j2 Category Names
Use these category names to target specific Mango subsystems:
| Category | Subsystem |
|---|---|
com.serotonin.m2m2 | All core Mango code (Serotonin packages) |
com.infiniteautomation.mango | All core Mango code (IA packages) |
com.serotonin.m2m2.db | Database operations |
com.serotonin.m2m2.email | Email sending |
com.serotonin.m2m2.i18n | Translation/internationalization |
com.serotonin.m2m2.rt | Real-time runtime (data sources, event detectors) |
com.serotonin.m2m2.web.mvc.rest | REST API |
com.serotonin.m2m2.rt.event | Event detectors |
com.serotonin.m2m2.rt.maint | Backups and purges |
com.serotonin.m2m2.rt.dataSource | Core data source code |
com.serotonin.m2m2.rt.publish | Core publisher code |
com.serotonin.m2m2.rt.script | Java scripting engine |
com.serotonin.ma.bacnet | BACnet module |
com.serotonin.bacnet4j | BACnet protocol library |
com.serotonin.m2m2.snmp | SNMP module |
org.snmp4j | SNMP protocol library |
Using Mango Properties in Log4j2
You can reference mango.properties values in the log4j2.xml file using the syntax ${mango:property.name}. For example:
<PatternLayout pattern="${mango:appender.stdout.pattern}"/>
This allows the logging configuration to adapt based on your Mango environment settings without hardcoding paths or patterns.
Full Configuration Example
A complete log4j2.xml file with rolling log files, corruption detection, and script logging is shown below. This is the default configuration that ships with Mango:
<?xml version="1.0" encoding="UTF-8" ?>
<Configuration packages="com.serotonin.m2m2.rt.console">
<Appenders>
<Console name="stdout" target="SYSTEM_OUT">
<PatternLayout pattern="${mango:appender.stdout.pattern}"/>
</Console>
<RollingRandomAccessFile name="logfile"
filePattern="${mango:paths.logs}/%d{MM-dd-yyyy}-%i.ma.log.gz"
fileName="${mango:paths.logs}/ma.log">
<PatternLayout pattern="${mango:appender.logfile.pattern}"/>
<Policies>
<OnStartupTriggeringPolicy />
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="${mango:appender.logfile.size}"/>
</Policies>
<DefaultRolloverStrategy fileIndex="nomax">
<Delete basePath="${mango:paths.logs}">
<IfFileName glob="*.ma.{log,log.gz}" />
<IfAny>
<IfLastModified age="${mango:appender.logfile.delete.age}" />
<IfAccumulatedFileSize exceeds="${mango:appender.logfile.delete.size}" />
<IfAccumulatedFileCount exceeds="${mango:appender.logfile.delete.count}" />
</IfAny>
</Delete>
</DefaultRolloverStrategy>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<!-- Add your custom debug loggers here -->
<AsyncLogger name="com.serotonin.m2m2"
includeLocation="${mango:logger.mango.includeLocation}"
level="${mango:logger.mango.level}"/>
<AsyncLogger name="com.infiniteautomation"
includeLocation="${mango:logger.mango.includeLocation}"
level="${mango:logger.mango.level}"/>
<AsyncRoot includeLocation="${mango:logger.root.includeLocation}"
level="${mango:logger.root.level}">
<AppenderRef ref="logfile" level="${mango:appender.logfile.level}" />
<AppenderRef ref="stdout" level="${mango:appender.stdout.level}" />
</AsyncRoot>
</Loggers>
</Configuration>
Common Issues
Log4j2 File in Wrong Directory
If debug logging does not appear after making changes, verify that log4j2.xml is in the correct directory. Open mango.properties and check the paths.data entry. If empty, the path is relative to paths.home. If that is also empty, the file should be placed in the Mango root directory (MA_HOME).
Log Files Growing Too Large
Debug logging can generate very large log files. Always use the most specific category possible (e.g., com.serotonin.m2m2.snmp instead of com.serotonin.m2m2) and remember to revert to info level when debugging is complete.
Related Pages
- Logging Console — View and download log files from the Mango UI
- Mango Properties Reference — The
log4j2.configurationFileproperty and logging-related settings - Managing Disk Space — Prevent debug logs from filling the disk
- Linux Diagnostic Information — Additional JVM diagnostic tools for deeper analysis
- Threads — Correlate debug log output with thread states and stack traces