Overview
go_logs supports configuration via environment variables, making it easy to adjust logging behavior across different environments without code changes. Environment variables are automatically loaded when using the v2 legacy API or can be manually loaded for v3 loggers.Log Level
LOG_LEVEL
Sets the minimum log level threshold. Only messages at or above this level will be logged. Type: String (case-insensitive) Valid Values:trace- Extremely detailed, high-volume logging (Level 10)debug- Detailed diagnostic information (Level 20)info- General informational messages (Level 30, default)warnorwarning- Warning messages (Level 40)error- Error events (Level 50)fatal- Critical errors that terminate the app (Level 60)silent,none, ordisable- Disable all logging (Level 0)
Output Format
LOG_FORMAT
Sets the output format for log entries. Type: String (case-insensitive) Valid Values:text- Human-readable text with colors (default)json- Structured JSON for log aggregation
text
Example:
File Logging
SAVE_LOG_FILE
Enables or disables logging to a file. Type: Boolean (0 or 1)
Default: 0 (disabled)
Example:
LOG_FILE_NAME
Sets the name of the log file. Type: String Default:log.txt
Example:
LOG_FILE_PATH
Sets the directory path for log files. Type: String (directory path) Default: Current directory (.)
Example:
File Rotation (v3)
LOG_MAX_SIZE
Maximum log file size in megabytes before rotation occurs. Type: Integer (MB) Default:100 MB
Example:
LOG_MAX_BACKUPS
Maximum number of backup files to keep after rotation. Type: Integer Default:5
Example:
Slack Notifications
SLACK_TOKEN
Slack bot token for sending notifications. Type: String (OAuth token) Format:xoxb-...
Example:
SLACK_CHANNEL_ID
Slack channel ID where notifications will be sent. Type: String (Channel ID) Format:C... or G...
Example:
NOTIFICATIONS_SLACK_ENABLED
Enables or disables Slack notifications. Type: Boolean (0 or 1)
Default: 0 (disabled)
Example:
Legacy Notification Levels (v2)
These variables control which log levels trigger Slack notifications in the v2 API. If any are set, they take precedence overLOG_LEVEL for backward compatibility.
NOTIFICATION_FATAL_LOG
Send fatal logs to Slack. Type: Boolean (0 or 1)
Default: 0
Example:
NOTIFICATION_ERROR_LOG
Send error logs to Slack. Type: Boolean (0 or 1)
Default: 0
Example:
NOTIFICATION_WARNING_LOG
Send warning logs to Slack. Type: Boolean (0 or 1)
Default: 0
Example:
NOTIFICATION_INFO_LOG
Send info logs to Slack. Type: Boolean (0 or 1)
Default: 0
Example:
NOTIFICATION_SUCCESS_LOG
Send success logs to Slack. Type: Boolean (0 or 1)
Default: 0
Example:
Configuration Priority
go_logs uses the following priority for configuration (highest to lowest):- Programmatic configuration (v3
New()options) - Legacy notification variables (
NOTIFICATION_*_LOG) - LOG_LEVEL environment variable
- Default values (InfoLevel, text format, etc.)
Environment Configuration Examples
Development Environment
Staging Environment
Production Environment
Docker Configuration
Kubernetes Configuration
Loading Environment Variables
v2 API (Automatic)
The v2 API automatically loads environment variables whenInit() is called:
v3 API (Manual)
The v3 API requires explicit configuration, but you can load from environment:Next Steps
- Configuration Options - Programmatic configuration
- Output Destinations - File rotation and multiple outputs
- Quick Start - Basic usage examples