Console UI (Log4j2)
Custom OK (350) log level, colored %levelBadge tags, %highlightApis line colors, and file vs terminal formatting.
Apis updates terminal console formatting (TerminalConsole in log4j2.xml.patch) using two custom Log4j2 converters under org.apismc.apis.console: ApisHighlightConverter and ApisLevelBadgeConverter.
Custom OK Log Level (Priority 350)
Section titled “Custom OK Log Level (Priority 350)”ApisLog and ApisLevelBadgeConverter register a custom Log4j2 level:
Level.forName("OK", 350)- Priority 350 sits between
WARN(300) andINFO(400). - Because it ranks above
INFO(400), standard<AppenderRef ref="TerminalConsole" level="info"/>and<Root level="info">filters passOKmessages through without extra logger rules. ApisLevelBadgeConverter#isOkEvent(LogEvent)also detects events carrying the"OK"marker when severity is not aboveWARN.
log4j2.xml Patterns & Converters
Section titled “log4j2.xml Patterns & Converters”Terminal Appender (TerminalConsole)
Section titled “Terminal Appender (TerminalConsole)”log4j2.xml.patch uses compact patterns for console output:
- Standard loggers:
%highlightApis{[%d{HH:mm:ss}] %levelBadge [%logger] %msg%n%xEx{full}}
- System / Minecraft / Mojang loggers (drops redundant logger name):
%highlightApis{[%d{HH:mm:ss}] %levelBadge %msg%n%xEx{full}}
File Appender (logs/latest.log)
Section titled “File Appender (logs/latest.log)”RollingRandomAccessFile name="File" stays unchanged. Log files still receive clean plain text stripped of ANSI codes (%stripAnsi{%msg}) in the standard [%d{HH:mm:ss}] [%t/%level]: ... format.
Color Rules for %highlightApis and %levelBadge
Section titled “Color Rules for %highlightApis and %levelBadge”%highlightApis (ApisHighlightConverter)
Section titled “%highlightApis (ApisHighlightConverter)”Colors the entire log line when TerminalConsoleAppender.isAnsiSupported() is true and appends reset code ESC[m:
| Level / Marker | ANSI Code | Color |
|---|---|---|
ERROR / FATAL |
ESC[31;1m |
Bright red |
WARN |
ESC[33;1m |
Bright yellow |
OK (level or marker) |
ESC[32;1m |
Bright green |
INFO, DEBUG, others |
- | Default terminal foreground |
%levelBadge (ApisLevelBadgeConverter)
Section titled “%levelBadge (ApisLevelBadgeConverter)”Builds a high-contrast level badge and restores the parent line color right after it:
| Level | ANSI Enabled | Plain Text (isAnsiSupported() == false) |
|---|---|---|
ERROR / FATAL |
ESC[0;1;30;101m <LEVEL> ESC[0;31;1m (bold black on red) |
Plain level (ERROR / FATAL) |
WARN |
ESC[0;1;30;103m <LEVEL> ESC[0;33;1m (bold black on yellow) |
WARN |
OK |
ESC[0;1;30;102m OK ESC[0;32;1m (bold black on green) |
OK |
INFO & others |
Plain level name without badge (INFO) |
Plain level name |
Core Log Messages (ApisLog.ok & Compact WARN)
Section titled “Core Log Messages (ApisLog.ok & Compact WARN)”Key startup and diagnostic events log at level OK:
ApisConfig.loadEarly:Loaded <path> (active kill-switches: <N>)DedicatedServer.java.patch:Done preparing level "<name>" (<time>s)MinecraftServer.java.patch:Done (<time>s)! For help, type "help"StandaloneWorldManager:Initialized standalone fallback world '...' at ...andLoaded standalone world '...' from ...ApisHooks.tryBreakStaleSessionLock:Cleared stale session.lock for world '...' (previous process not running)ApisDiagnostics.warnBlocked:Blocked plugin '<name>'|server call <ctx>(<target>) - disabled by <key> in apis.yml