Development Guide
Observability
Understanding how to use the logging and debugging system in Motia
Overview
Motia provides an out of the box logging and debugging system that works across different runtime environments. The system offers:
- Real-time log streaming in both terminal and Motia Workbench
- Multiple log levels with contextual information
- Local development debugging tools
- Integrated flow monitoring
Log Levels and Usage
Motia supports four standard log levels:
Log Type | Description |
---|---|
info | General information about step execution, flow progress, and successful operations |
error | Critical issues, exceptions, failed operations, and system errors |
debug | Detailed debugging information and diagnostic data for troubleshooting |
warn | Potential issues, edge cases, or situations requiring attention |
Example Usage
Running and Debugging
Start the Dev Server
- Navigate to your Motia project root folder
- Start the development server:
npm run dev
- You can monitor logs in two ways:
- Open Motia Workbench, select your flow, and expand the logs container
- View logs directly in the terminal where you ran the dev command
Debug Using Logs
Each log entry automatically includes:
timestamp
: When the log was generatedtraceId
: Unique identifier for the flow executionflows
: Array of flow names this step belongs tofile
: Source file generating the loglevel
: Log levelmsg
: Log message
Stopping the development server
Press Ctrl + C (or Cmd + C on macOS) in your terminal. That's it!
Best Practices
Structured Logging
Performance Monitoring
Debugging Tips
- Add detailed context to error logs:
- Use debug logs for detailed troubleshooting:
Remember to stop your development server with Ctrl + C (or Cmd + C on macOS) when you're done debugging.
Need help? See our Community Resources for questions, examples, and discussions.