Log Management
Scout’s Log Management feature allows you to monitor, search, and analyze your Elixir application logs directly within the Scout UI. By integrating with our existing APM agent, we provide enhanced context and filtering capabilities.
Installation
AIf you haven't already, set up Scout APM for Elixir.
BEnable log management in your config and provide an ingest key (available in the Logs page of your Scout app):
config :scout_apm,
logs_enabled: true,
logs_ingest_key: "your-logs-ingest-key"
CAttach the log handler in your Application.start/2:
def start(_type, _args) do
ScoutApm.Logging.attach()
# ...
end
DDeploy!
It takes approximately five minutes for your data to first appear within the Scout UI.
Configuration Options
The following configuration settings are available. These can be set in your config/scout_apm.exs file or as environment variables with the SCOUT_ prefix, e.g. SCOUT_LOGS_INGEST_KEY.
Only logs_ingest_key is required. The rest are optional.
| Setting Name | Description | Default | Required |
|---|---|---|---|
| logs_enabled | Enable or disable log forwarding to Scout. | false |
Yes |
| logs_ingest_key | The ingest API key for log forwarding. Available in the Logs page of your Scout app. Falls back to the main key if not set. |
nil |
Yes |
| logs_endpoint | The OTLP endpoint where logs are sent. | https://otlp.scoutotel.com:4318 |
No |
| logs_batch_size | Number of log records sent per batch. | 100 |
No |
| logs_max_queue_size | Maximum number of log records queued before dropping. | 5000 |
No |
| logs_flush_interval_ms | How often (in milliseconds) the log queue is flushed. | 5000 |
No |
| logs_level | The minimum log level to forward. Possible values: :debug, :info, :warning, :error. |
:info |
No |
| logs_filter_modules | A list of logger module names to exclude from forwarding. | [] |
No |
Example configuration:
config :scout_apm,
logs_enabled: true,
logs_ingest_key: "your-key",
logs_level: :info,
logs_filter_modules: []
How It Works
Scout integrates with Elixir’s built-in Logger via a custom handler. Once enabled, no changes to your existing logging code are required. The handler forwards log entries directly to Scout using the OTLP protocol.
The logs will be available in the Scout UI for you to search and filter. Your original logs are not altered.
Default Attributes
The Scout Logs handler enriches Elixir logs with attributes by default:
- entrypoint: The top-level action (e.g. Controller module) that the log was generated from.
- request_id: The request ID for the current request, when available.
- transaction_name: The Scout transaction name associated with the log entry.
In addition, it will capture all key-value pairs from any Custom Context that you have set. This means logs can be filtered by any Custom Context attributes.
Data Retention
Scout retains your log data for 14 days. If you require longer-term storage, please let us know as we would like to create options for our customers, but at this point you will need to also send them to an alternative location.