Viewing Logs
Expose provides real-time access to both build logs and container runtime logs.
Build Logs
Viewing Build Logs
- Go to the deployment detail
- Click on a build in the Builds list
- View the log output
Build Log Contents
Build logs show the Docker build process:
Step 1/8 : FROM node:20-alpine ---> 1a2b3c4d5e6fStep 2/8 : WORKDIR /app ---> Running in abc123def456 ---> 7g8h9i0j1k2lStep 3/8 : COPY package*.json ./ ---> 3m4n5o6p7q8rStep 4/8 : RUN npm ci ---> Running in rst123uvw456
added 150 packages in 12s...Successfully built xyz789abc012Successfully tagged registry:5000/myapp:abc123Live Streaming
During builds, logs stream in real-time:
- Trigger a deploy
- Watch the build progress
- See each step as it completes
Build Errors
If a build fails, the logs show the error:
Step 5/8 : RUN npm run build ---> Running in abc123def456npm ERR! Missing script: "build"npm ERR!The command '/bin/sh -c npm run build' returned a non-zero code: 1Runtime Logs
Viewing Container Logs
- Go to the deployment detail
- Click View Logs or the Logs tab
- See recent container output
Log Contents
Container logs show your application’s stdout/stderr:
2024-01-15T10:30:00Z INFO Starting server on port 30002024-01-15T10:30:01Z INFO Connected to database2024-01-15T10:30:05Z INFO GET /api/users 200 15ms2024-01-15T10:30:10Z WARN Rate limit approaching2024-01-15T10:30:15Z ERROR Connection timeout to external serviceLive Tailing
To follow logs in real-time:
- Open the logs view
- New logs appear automatically
- Scroll to pause auto-follow
Log Levels
Structure your app’s logging for better visibility:
// Good: Different levelsconsole.log('INFO: Server started');console.warn('WARN: Slow query detected');console.error('ERROR: Failed to connect');
// Better: Structured loggingconst log = require('pino')();log.info({ port: 3000 }, 'Server started');log.error({ err, userId: 123 }, 'Failed to process request');Log Retention
| Log Type | Retention |
|---|---|
| Build logs | Kept with build record (indefinite) |
| Container logs | Rolling window (~1000 lines) |
For longer retention, consider:
- External logging service
- Log aggregation tool
- Custom log shipping
Troubleshooting with Logs
App Won’t Start
Check container logs for startup errors:
Error: Cannot find module 'express' at Function.Module._resolveFilenameSolution: Ensure dependencies are installed in Dockerfile.
Health Check Failing
Look for:
Health check failed: Connection refusedSolution: Ensure app listens on correct port.
Crashes
Look for:
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failedSolution: Check memory usage, consider increasing limits.
Accessing Logs via SSH
For advanced debugging, SSH to your VPS:
# List containersdocker ps
# View logsdocker logs -f expose_myapp
# Follow with taildocker logs -f --tail 100 expose_myappLog Best Practices
- Log meaningful events — Startup, errors, important state changes
- Include context — Request IDs, user IDs, timestamps
- Use structured logging — JSON format for parsing
- Don’t log secrets — Mask sensitive data
- Set appropriate levels — Debug in dev, warn/error in prod