Environments

Azu supports three environments with different default behaviors.

Environment Enum

enum Azu::Environment
  Development
  Test
  Production
end

Setting Environment

Via Configuration

Azu.configure do |config|
  config.env = Azu::Environment::Production
end

Via Environment Variable

export AZU_ENV=production

Checking Environment

Development Environment

Default settings for development:

Setting
Value
Purpose

Log level

Debug

Detailed logging

Template hot reload

true

Immediate changes

Error pages

Detailed

Full stack traces

Cache

Memory

Simple, local

Behavior

  • Detailed error pages with stack traces

  • Templates reloaded on each request

  • Verbose logging of all requests

  • Development-friendly error messages

Configuration

Test Environment

Default settings for testing:

Setting
Value
Purpose

Log level

Warn

Less noise

Template hot reload

false

Faster tests

Error pages

Simple

JSON errors

Cache

Memory

Isolated

Behavior

  • Minimal logging to reduce noise

  • Cached templates for speed

  • JSON error responses

  • Isolated test database

Configuration

Test Setup

Production Environment

Default settings for production:

Setting
Value
Purpose

Log level

Info

Important events

Template hot reload

false

Performance

Error pages

Simple

Security

Cache

Redis

Distributed

Behavior

  • Minimal, structured logging

  • Compiled and cached templates

  • Generic error messages (no stack traces)

  • External cache (Redis)

  • SSL recommended

Configuration

Security Considerations

  • Stack traces hidden from users

  • Sensitive data not logged

  • HTTPS enforced

  • Security headers enabled

Environment Files

.env Files

Loading Environment

Complete Example

See Also

Last updated

Was this helpful?