Skip to content

Viewing Logs

Expose provides real-time access to both build logs and container runtime logs.

Build Logs

Viewing Build Logs

  1. Go to the deployment detail
  2. Click on a build in the Builds list
  3. View the log output

Build Log Contents

Build logs show the Docker build process:

Step 1/8 : FROM node:20-alpine
---> 1a2b3c4d5e6f
Step 2/8 : WORKDIR /app
---> Running in abc123def456
---> 7g8h9i0j1k2l
Step 3/8 : COPY package*.json ./
---> 3m4n5o6p7q8r
Step 4/8 : RUN npm ci
---> Running in rst123uvw456
added 150 packages in 12s
...
Successfully built xyz789abc012
Successfully tagged registry:5000/myapp:abc123

Live Streaming

During builds, logs stream in real-time:

  1. Trigger a deploy
  2. Watch the build progress
  3. 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 abc123def456
npm ERR! Missing script: "build"
npm ERR!
The command '/bin/sh -c npm run build' returned a non-zero code: 1

Runtime Logs

Viewing Container Logs

  1. Go to the deployment detail
  2. Click View Logs or the Logs tab
  3. See recent container output

Log Contents

Container logs show your application’s stdout/stderr:

2024-01-15T10:30:00Z INFO Starting server on port 3000
2024-01-15T10:30:01Z INFO Connected to database
2024-01-15T10:30:05Z INFO GET /api/users 200 15ms
2024-01-15T10:30:10Z WARN Rate limit approaching
2024-01-15T10:30:15Z ERROR Connection timeout to external service

Live Tailing

To follow logs in real-time:

  1. Open the logs view
  2. New logs appear automatically
  3. Scroll to pause auto-follow

Log Levels

Structure your app’s logging for better visibility:

// Good: Different levels
console.log('INFO: Server started');
console.warn('WARN: Slow query detected');
console.error('ERROR: Failed to connect');
// Better: Structured logging
const log = require('pino')();
log.info({ port: 3000 }, 'Server started');
log.error({ err, userId: 123 }, 'Failed to process request');

Log Retention

Log TypeRetention
Build logsKept with build record (indefinite)
Container logsRolling 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._resolveFilename

Solution: Ensure dependencies are installed in Dockerfile.

Health Check Failing

Look for:

Health check failed: Connection refused

Solution: Ensure app listens on correct port.

Crashes

Look for:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed

Solution: Check memory usage, consider increasing limits.

Accessing Logs via SSH

For advanced debugging, SSH to your VPS:

Terminal window
# List containers
docker ps
# View logs
docker logs -f expose_myapp
# Follow with tail
docker logs -f --tail 100 expose_myapp

Log Best Practices

  1. Log meaningful events — Startup, errors, important state changes
  2. Include context — Request IDs, user IDs, timestamps
  3. Use structured logging — JSON format for parsing
  4. Don’t log secrets — Mask sensitive data
  5. Set appropriate levels — Debug in dev, warn/error in prod