Environment Variable Configuration
Fapilog follows 12-factor conventions: every setting can be supplied via environment variables using the FAPILOG_ prefix and double-underscore nesting (e.g., FAPILOG_CORE__LOG_LEVEL). Short aliases exist for common sinks and guards so you don’t have to remember deeply nested names.
Naming Convention
Prefix:
FAPILOG_Nested fields:
__(double underscore)Lists: JSON strings (e.g.,
["stdout_json","audit"])Booleans:
true/false,1/0,yes/no
Example: FAPILOG_CORE__SINKS='["cloudwatch"]' maps to settings.core.sinks.
Size and duration fields accept human-readable strings (e.g., "10 MB", "5s") as
well as numeric values. Rotation intervals also accept "hourly", "daily", "weekly".
How Env Vars Are Resolved
Fapilog env vars fall into three categories:
Category |
Example |
How It Works |
|---|---|---|
Top-level |
|
Standard Pydantic parsing—these are top-level settings |
Short aliases |
|
Dedicated handlers map short forms to nested paths |
Full paths |
|
Require the complete nested path |
Short aliases like FAPILOG_CLOUDWATCH__REGION are convenience mappings—they’re equivalent to the full path FAPILOG_SINK_CONFIG__CLOUDWATCH__REGION but easier to type.
Quick Reference
Core Settings (top-level)
Variable |
Type |
Default |
Description |
|---|---|---|---|
|
string |
|
Minimum log level ( |
|
int |
|
Queue depth before backpressure/drop |
|
int |
|
Max events per flush batch |
|
float |
|
Max seconds before flushing a partial batch |
|
int |
|
Milliseconds to wait for space before dropping |
|
bool |
|
Drop when queue full after wait |
|
JSON list |
|
Sink plugin names (e.g., |
|
JSON list |
|
Filter plugin names |
|
bool |
|
Enable internal metrics |
|
float |
|
Suppress duplicate errors within window |
|
bool |
|
Enable sink circuit breakers |
|
bool |
|
Fan out writes in parallel |
File Sink (env-only shortcut)
When FAPILOG_FILE__DIRECTORY is set, the rotating file sink is auto-enabled without touching core.sinks.
Variable |
Type |
Default |
Description |
|---|---|---|---|
|
string |
unset |
Directory for rotated files |
|
string |
|
Filename prefix |
|
string |
|
|
|
size |
|
Rotate at/after this size (e.g., |
|
duration |
unset |
Optional time-based rotation (e.g., |
|
int |
unset |
Retain at most this many rotated files |
|
size |
unset |
Retain up to this many bytes across rotated files (e.g., |
|
bool |
|
Gzip rotated files |
CloudWatch Sink (short aliases)
Variable |
Type |
Default |
Description |
|---|---|---|---|
|
string |
|
Log group |
|
string |
unset |
Log stream |
|
string |
unset |
AWS region |
|
string |
unset |
Custom endpoint/LocalStack |
|
int |
|
Events per batch |
|
float |
|
Max seconds before flush |
|
bool |
|
Auto-create group |
|
bool |
|
Auto-create stream |
|
int |
|
Retry attempts |
|
float |
|
Backoff base seconds |
|
bool |
|
Enable sink CB |
|
int |
|
Failures to open circuit |
Loki Sink (short aliases)
Variable |
Type |
Default |
Description |
|---|---|---|---|
|
string |
|
Loki push endpoint |
|
string |
unset |
Tenant |
|
JSON object |
|
Static labels |
|
JSON list |
|
Event keys promoted to labels |
|
int |
|
Events per batch |
|
float |
|
Max seconds before flush |
|
float |
|
HTTP timeout |
|
int |
|
Retry attempts |
|
float |
|
Backoff base seconds |
|
bool |
|
Enable sink CB |
|
int |
|
Failures to open circuit |
|
string |
unset |
Basic auth username |
|
string |
unset |
Basic auth password |
|
string |
unset |
Bearer token |
PostgreSQL Sink (short aliases)
Variable |
Type |
Default |
Description |
|---|---|---|---|
|
string |
unset |
Full DSN (overrides host/port/db/user/pass) |
|
string |
|
Host |
|
int |
|
Port |
|
string |
|
Database |
|
string |
|
User |
|
string |
unset |
Password |
|
string |
|
Table |
|
string |
|
Schema |
|
bool |
|
Auto-create table |
|
bool |
|
Store payload as JSONB |
|
bool |
|
Store raw JSON alongside columns |
|
int |
|
Min pool size |
|
int |
|
Max pool size |
|
float |
|
Acquire timeout seconds |
|
int |
|
Events per batch |
|
float |
|
Max seconds before flush |
|
int |
|
Retry attempts |
|
float |
|
Backoff base seconds |
|
bool |
|
Enable sink CB |
|
int |
|
Failures to open circuit |
|
JSON list |
unset |
Fields to extract into columns |
HTTP Sink (top-level)
Variable |
Type |
Default |
Description |
|---|---|---|---|
|
string |
unset |
HTTP sink endpoint |
|
float |
|
Request timeout |
|
int |
unset |
Max retry attempts |
|
float |
unset |
Base backoff seconds |
|
int |
|
Events per request |
|
float |
|
Max seconds before flush |
|
string |
|
|
|
string |
|
Wrapper key for |
|
JSON object |
unset |
Headers map as JSON |
Webhook Sink (full path)
Variable |
Type |
Default |
Description |
|---|---|---|---|
|
string |
unset |
Webhook URL |
|
string |
unset |
Shared secret for signing |
|
JSON object |
|
Extra headers |
|
int |
unset |
Max retry attempts |
|
float |
unset |
Backoff seconds |
|
float |
|
Request timeout |
|
int |
|
Events per webhook call |
|
float |
|
Max seconds before flush |
Sink Routing (short aliases)
Variable |
Type |
Default |
Description |
|---|---|---|---|
|
bool |
|
Enable level-based routing |
|
bool |
|
Allow overlapping routes |
|
JSON list |
|
Routing rules list |
|
JSON list |
|
Fallback sink names |
Size Guard Processor (short aliases)
Variable |
Type |
Default |
Description |
|---|---|---|---|
|
string |
|
Action on oversize ( |
|
size |
|
Max bytes before action (e.g., |
|
JSON list |
|
Fields to keep when truncating |
Runtime Info Enricher (common env helpers)
Variable |
Type |
Default |
Description |
|---|---|---|---|
|
string |
|
Service name emitted by |
|
string |
|
Environment name |
|
string |
unset |
Service/app version |
Deployment Examples
Kubernetes (ConfigMap/Env)
apiVersion: v1
kind: ConfigMap
metadata:
name: fapilog-config
data:
FAPILOG_CORE__LOG_LEVEL: "INFO"
FAPILOG_CORE__SINKS: '["cloudwatch"]'
FAPILOG_CLOUDWATCH__LOG_GROUP_NAME: "/myapp/prod"
FAPILOG_CLOUDWATCH__REGION: "us-east-1"
Docker Compose
services:
app:
environment:
FAPILOG_CORE__LOG_LEVEL: DEBUG
FAPILOG_CORE__SINKS: '["loki"]'
FAPILOG_LOKI__URL: http://loki:3100
FAPILOG_LOKI__LABELS: '{"service":"app","env":"dev"}'
Heroku / Railway
heroku config:set FAPILOG_CORE__LOG_LEVEL=INFO
heroku config:set FAPILOG_POSTGRES__DSN=$DATABASE_URL
heroku config:set FAPILOG_CORE__SINKS='["postgres"]'
Tips
Prefer JSON strings for lists/objects to avoid parsing surprises.
Short aliases (e.g.,
FAPILOG_LOKI__...) override nested settings and keep manifests readable.Keep secrets in your secrets manager (Kubernetes Secret, Docker secrets, etc.) instead of ConfigMaps.
Complete Reference
This guide covers the most commonly used settings. For the exhaustive list of all 200+ env vars (including advanced security, observability, and plugin settings), see the auto-generated Environment Variables Reference.