generated from dynatrace-oss/template-project
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
bugSomething isn't workingSomething isn't working
Description
LOG_OUTPUT=console Not Working with stdio Transport and Logs in Unreadable JSON Format
Problem
When setting LOG_OUTPUT=console with LOG_LEVEL=debug in VS Code (stdio transport), debug logs were not visible in the Output panel. Additionally, when logs did appear on console outputs, they were in JSON format which was difficult to read.
Current Behavior (Before Fix)
-
LOG_OUTPUT=console with stdio transport: Logs disappeared completely
- Users set
LOG_OUTPUT=consoleandLOG_LEVEL=debug - Expected to see debug logs in VS Code Output panel
- Only saw VS Code's own messages, no MCP server logs
- Users set
-
Logs in JSON format: When logs did reach console (stderr or HTTP mode), they were unreadable:
{"level":"info","message":"Starting Dynatrace Managed MCP","timestamp":"2026-02-05T14:02:01.467Z"} {"level":"debug","message":"Loading configuration from file: .ai/mcp/dt-config.yaml","timestamp":"2026-02-05T14:02:01.470Z"} -
No guidance: Documentation didn't explain:
- Why
LOG_OUTPUT=consoledoesn't work with stdio transport - Which
LOG_OUTPUTto use for stdio vs HTTP transport - No warning when using wrong configuration
- Why
Root Cause
With stdio transport (default for VS Code):
- stdout is reserved for MCP protocol messages - winston logs to stdout are consumed by the protocol parser and never displayed
- stderr is the only viable channel for human-readable logs
- Winston was configured to always output JSON format, which is hard to read for humans
Expected Behavior
- Clear documentation on which
LOG_OUTPUTworks with which transport - Runtime warning when user sets incompatible LOG_OUTPUT configuration
- Human-readable format for console/stderr output (save JSON for file output)
Solution
1. Add Human-Readable Console Format (src/utils/logger.ts)
- Detect when LOG_OUTPUT targets console/stderr
- Use readable format:
2026-02-05 14:02:01.467 [info] Starting Dynatrace Managed MCP - Keep JSON format for file output (machine parsing)
2. Add Runtime Warning (src/index.ts)
When stdio transport detects LOG_OUTPUT=console/stdout/file+console/file+stdout:
WARNING: LOG_OUTPUT=console won't show logs in stdio transport.
Stdout is reserved for MCP protocol. Use LOG_OUTPUT=stderr-all or LOG_OUTPUT=file instead.
3. Update Documentation (README.md)
- Document which LOG_OUTPUT works with stdio vs HTTP transport
- Provide clear examples for VS Code setup
- Add IMPORTANT callout box explaining stdout limitation
- Recommend
LOG_OUTPUT=stderr-allfor VS Code with stdio transport
Impact
- Severity: Medium - Users couldn't debug issues effectively
- Affected Users: Anyone using stdio transport (VS Code, Claude Desktop) trying to see debug logs
- Workaround (before fix): Use
LOG_OUTPUT=fileand tail the log file
Files Changed
src/utils/logger.ts- Add human-readable format for console outputsrc/index.ts- Add runtime warning for incompatible LOG_OUTPUT with stdioREADME.md- Document LOG_OUTPUT behavior with transport types
Testing
Verify the following scenarios:
Stdio transport (VS Code):
- ✅
LOG_OUTPUT=stderr-all LOG_LEVEL=debug- logs visible and readable in Output panel - ✅
LOG_OUTPUT=file LOG_LEVEL=debug- logs written to file in JSON format - ✅
LOG_OUTPUT=console- shows warning message to stderr
HTTP transport:
- ✅
LOG_OUTPUT=console LOG_LEVEL=debug- logs visible and readable in terminal - ✅
LOG_OUTPUT=file LOG_LEVEL=debug- logs written to file in JSON format
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working