Skip to main content
The Flora CLI provides commands to fetch and stream logs from the runtime. Logs include all output from your deployed scripts, including errors, warnings, and custom log messages.

Fetching Recent Logs

Retrieve the most recent logs for a guild:
flora logs --guild 123456789012345678
By default, this fetches the last 100 log entries.

Limit Results

Control the number of log entries returned:
flora logs --guild 123456789012345678 --limit 50
Or use the short form:
flora logs --guild 123456789012345678 -n 50

Streaming Logs

Follow logs in real-time as they’re generated:
flora logs --guild 123456789012345678 --follow
Or use the short form:
flora logs --guild 123456789012345678 -f
Press Ctrl+C to stop streaming.
Streaming uses Server-Sent Events (SSE) to push new log entries to the CLI as they occur.

Log Format

Log entries are displayed with the following format:
2024-03-15 10:30:45.123 INFO [123456789012345678] flora::runtime: Bot initialized
2024-03-15 10:30:46.456 DEBUG [123456789012345678] my_bot::commands: Registered 5 commands
2024-03-15 10:31:02.789 WARN [123456789012345678] my_bot::handler: Rate limit warning
Format breakdown:
  • 2024-03-15 10:30:45.123 - Timestamp (ISO 8601 format)
  • INFO - Log level (color-coded)
  • [123456789012345678] - Guild ID
  • flora::runtime - Log target (module/component)
  • Bot initialized - Log message

Log Levels

Logs are color-coded by severity:
ERROR - Critical errors (red)

Viewing All Logs

View logs across all guilds (requires appropriate permissions):
flora logs
This shows logs from all deployments, not just a single guild.

Example Log Output

Successful Deployment

$ flora logs --guild 123456789012345678 --limit 10
2024-03-15 10:30:45.123 INFO [123456789012345678] flora::runtime: Starting bot execution
2024-03-15 10:30:45.234 INFO [123456789012345678] flora::runtime: Loaded 3 prefix commands
2024-03-15 10:30:45.345 INFO [123456789012345678] flora::runtime: Loaded 5 slash commands
2024-03-15 10:30:45.456 INFO [123456789012345678] flora::discord: Connected to Discord gateway
2024-03-15 10:30:45.567 INFO [123456789012345678] my_bot: Bot is ready!

Error Debugging

$ flora logs --guild 123456789012345678 -f
Streaming logs... (press Ctrl+C to stop)
2024-03-15 10:35:12.123 INFO [123456789012345678] my_bot::commands: Processing command: !ping
2024-03-15 10:35:12.234 ERROR [123456789012345678] my_bot::commands: Failed to send message: Missing permissions
2024-03-15 10:35:12.345 WARN [123456789012345678] flora::runtime: Command handler returned error

Use Cases

Debugging Command Errors

When a command fails, check logs to see the error:
flora logs --guild 123456789012345678 --limit 20
Look for ERROR or WARN level messages.

Monitoring Bot Activity

Stream logs to watch bot activity in real-time:
flora logs --guild 123456789012345678 --follow

Verifying Deployments

After deploying, check that the bot started correctly:
flora logs --guild 123456789012345678 --limit 5
Look for initialization messages like “Bot is ready!” or “Connected to Discord gateway”.

Programmatic Logging

In your bot code, use the runtime’s logging functions to generate custom log entries:
// These will appear in the CLI logs
console.log('Info message')      // INFO level
console.warn('Warning message')  // WARN level
console.error('Error message')   // ERROR level
All console.* calls in your bot code are captured and sent to the logging system with appropriate log levels.

Filtering and Searching

While the CLI doesn’t have built-in filtering, you can use standard Unix tools:
# Show only errors
flora logs --guild 123456789012345678 | grep ERROR

# Search for specific text
flora logs --guild 123456789012345678 | grep "command handler"

# Tail logs and filter
flora logs --guild 123456789012345678 -f | grep -i "error\|warn"

Troubleshooting

No Logs Appearing

If no logs are shown:
  1. Verify the guild has an active deployment:
    flora get --guild 123456789012345678
    
  2. Check that the bot is running and generating logs
  3. Try increasing the limit:
    flora logs --guild 123456789012345678 --limit 500
    

Stream Disconnects

If streaming disconnects frequently, check your network connection or API URL configuration.

Next Steps

Deploy Scripts

Deploy updated code to fix issues found in logs

KV Operations

Debug data storage issues with KV commands

Build docs developers (and LLMs) love