Skip to content

run --local: attach a file log subscriber so application logs are captured#39

Merged
ako merged 1 commit into
mainfrom
fix/runtime-log-subscriber
Jul 26, 2026
Merged

run --local: attach a file log subscriber so application logs are captured#39
ako merged 1 commit into
mainfrom
fix/runtime-log-subscriber

Conversation

@ako

@ako ako commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary

Round 2 of findings #25. PR #38 tee'd the runtime JVM's stdout/stderr to .mxcli/runtime.log, but a re-test on the Sudoku app showed the file stays nearly empty: microflow LOG output and server-side exception stack traces never appear, so a page-action error still can't be diagnosed (the browser only shows the generic Mendix dialog).

Root cause: a standalone runtime launched via runtimelauncher.jar attaches no log subscriber by default — unlike a Studio Pro / m2ee run, which calls create_log_subscriber after start. Mendix application logs flow to log subscribers, not stdout, so with none attached they go nowhere.

Fix

After a successful start (and on every restart's Start, since each fresh JVM has no subscriber), attach a file log subscriber via the create_log_subscriber admin action, mirroring m2ee-tools' post-start _configure_logging:

{ type: "file", name: "mxcli-run-local", autosubscribe: "INFO",
  filename: <abs runtime.log>, max_size: 1 GiB, max_rotate: 0 }
  • max_rotate: 0 is load-bearing — the JVM stdout tee (PR run --local: tee the Mendix runtime log to a file for debugging #38) holds an open fd on the same file, and a rotate-rename would detach it. Both writers append.
  • The path is passed absolute (the runtime's cwd is <install>/runtime, not mxcli's).
  • Best-effort: a logging failure warns to stdout rather than failing an otherwise-healthy start. Disabling the file with --runtime-log - disables the subscriber too.

Tests

  • TestStart_AttachesLogSubscriber — asserts the params (type/filename/autosubscribe/name/max_rotate:0) after a successful start.
  • TestStart_NoLogSubscriberWhenUnset — no subscriber when LogSubscriberFile is empty.
  • TestStart_LogSubscriberFailureNonFatal — a failing create_log_subscriber does not fail Start; it warns instead.

All docker unit tests pass; the only failure is the pre-existing environmental TestServeIntegration (test app 11.6.3 vs MxBuild cache 11.12.1), unrelated to this change.

Docs

  • run help text, run-local skill, and docs-site "Debugging a server-side error" now explain that two sources feed runtime.log (JVM tee + file log subscriber) and why.
  • fix-issue.md symptom table extended with the round-2 entry.

🤖 Generated with Claude Code


Generated by Claude Code

…tured

The runtime-log tee added earlier writes the runtime JVM's stdout/stderr to
.mxcli/runtime.log, but a standalone runtime (launched via runtimelauncher.jar)
attaches no log subscriber by default — unlike a Studio Pro / m2ee run, which
calls create_log_subscriber after start. Mendix application logs flow to log
subscribers, not stdout, so microflow LOG output and server-side exception
stack traces never reached the file: a page-action error still showed only the
generic Mendix dialog with nothing to correlate against.

After a successful start (and on every restart's Start, since each fresh JVM
starts with no subscriber), attach a "file" log subscriber pointing at the same
runtime.log with autosubscribe INFO. max_rotate is 0 so the runtime never
renames the file out from under the JVM tee's open handle; the path is passed
absolute because the runtime's cwd is <install>/runtime, not mxcli's. The
attach is best-effort — a logging failure warns to stdout rather than failing
an otherwise-healthy start.

Tests: TestStart_AttachesLogSubscriber (params), TestStart_NoLogSubscriberWhenUnset,
TestStart_LogSubscriberFailureNonFatal. Docs: run-local skill, docs-site, and the
fix-issue symptom table (findings #25, round 2).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JXnEgoc2NQP1Y2TWMCMXC4
@ako
ako merged commit a2f8d82 into main Jul 26, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants