Log Management
Runix captures stdout and stderr from every managed process into separate log files with optional rotation.
Log Storage
~/.runix/apps/<name>/
├── stdout.log # Captured stdout
└── stderr.log # Captured stderr
Log Format
Each line is prefixed with a timestamp and source marker by the PrefixWriter:
2025-01-15 10:30:00 [out] Server listening on :8080
2025-01-15 10:30:01 [out] Connected to database
2025-01-15 10:30:05 [err] Connection timeout to redis
2025-01-15 10:30:06 [err] Retry attempt 1/3
Implementation
Capture
Process output is captured via exec.Cmd pipes:
cmd.StdoutPipe()→ connected to aPrefixWriterwrapping the log filecmd.StderrPipe()→ connected to a separatePrefixWriter- Each writer prepends timestamps and
[out]/[err]markers - Writes are mutex-protected for thread safety
Rotation
Located at internal/logrot/rotator.go, the Rotator provides size-based log rotation:
func NewRotator(path string, maxSize int64, maxFiles int, maxAge time.Duration) (*Rotator, error)
Configuration
processes:
api:
entrypoint: ./cmd/api
logging:
max_size: 10485760 # 10MB in bytes
max_files: 5 # Keep 5 rotated files
max_age: 168h # 7 days
Rotation Process
- Before each write, check if
current_size + write_size >= max_size - If so, rotate:
- Close the current file
- Rename to
<name>.log.<timestamp>(e.g.,stdout.log.2025-01-15T10-30-00) - Open a new file at the original path
- Prune old files
- Pruning removes files exceeding
max_filescount ormax_ageduration
Pruning Rules
| Rule | Behavior |
|---|---|
max_files > 0 | Keep only the N newest rotated files |
max_age > 0 | Remove files older than the duration |
| Both | Both rules applied |
Default Values
| Setting | Default |
|---|---|
max_size | 10MB (10,485,760 bytes) |
max_files | 5 |
max_age | 168h (7 days) |
Log Commands
# View last 50 lines
runix logs api
# Stream live output
runix logs api --follow
# View stderr
runix logs api --stderr
# Error lines only
runix logs api --error
# Truncate log files
runix flush api
runix flush # All apps
What's Next
- Logs Command — CLI usage
- Flush Command — Clear log files
- Configuration Reference — Logging config fields