Application Logs

Learn how to view logs of an application in Andasy

The logs command allows you to view logs from your applications running on Andasy. Logs are essential for understanding what your application is doing, debugging issues, and monitoring application health.

What are Logs?

Logs are records of events, messages, and errors generated by your application as it runs. They include:

  • Application output - Messages your application prints (e.g., console.log, print())
  • Error messages - Exceptions, stack traces, and error details
  • System events - Container startup, shutdown, and system-level messages
  • Request logs - HTTP requests, API calls, and network activity (if logged by your app)

Andasy automatically collects logs from all machines running your application, making them accessible through the CLI without needing to SSH into machines.

Viewing Logs

The logs command provides flexible options for viewing logs:

  • Stream logs in real-time - Watch logs as they're generated (default behavior)
  • Fetch recent logs - Get logs from a specific time period without streaming
  • Filter by level - Show only errors, warnings, or specific log levels
  • Filter by machine - View logs from a specific machine
  • Filter by time - Get logs from the last hour, day, week, etc.

Usage

andasy logs [flags]

Aliases

  • logs
  • log

Flags

FlagDescription
-a, --app stringSpecify the target Andasy app.
-f, --from stringGet logs not older than this time. Formats: y, w, d, h, m, s (default: 1h).
-h, --helpShow help for the logs command.
-l, --level stringFilter logs by level: error, warn, info, debug (default: all).
-m, --machine stringSpecify the target machine app.
-t, --tailReturn only the current logs in the system (does not stream new logs).

Examples

Stream Logs in Real-Time (Default)

Watch logs as they're generated:

andasy logs -a my-app

Press Ctrl+C to stop streaming.

Fetch Recent Logs Without Streaming

Get the latest logs and exit (useful for scripts):

andasy logs -a my-app --tail

Filter by Log Level

View only error-level logs:

andasy logs -a my-app --level error

Available levels: error, warn, info, debug, all (default)

View Logs from a Specific Time Period

Get logs from the last 24 hours:

andasy logs -a my-app --from 24h

Time formats: y (year), w (week), d (day), h (hour), m (minute), s (second)

Examples:

  • --from 1h - Last hour
  • --from 7d - Last 7 days
  • --from 30m - Last 30 minutes

View Logs from a Specific Machine

If your application has multiple machines, view logs from just one:

andasy logs -a my-app -m <machine-id>

Get the machine ID from andasy machines list -a my-app.

Combine Filters

Combine multiple filters for precise log viewing:

# Error logs from the last 2 hours, no streaming
andasy logs -a my-app --level error --from 2h --tail

Log Levels

Log levels help you filter and prioritize log messages:

  • error - Critical errors that need immediate attention
  • warn - Warnings about potential issues
  • info - General informational messages (default application output)
  • debug - Detailed debugging information
  • all - Show all log levels (default)

Your application's logging framework determines the log level. Make sure your application uses standard logging levels for effective filtering.

Best Practices

  1. Use log levels appropriately - Structure your application logs with proper levels
  2. Monitor errors regularly - Set up alerts or regularly check error logs
  3. Use time filters - When debugging, narrow down the time range to find relevant logs
  4. Combine with metrics - Use logs alongside andasy metrics for comprehensive monitoring