Logging From ElixirBETA
This documentation outlines how to configure logging with the AppSignal for Elixir integration.
mix deps.update appsignal
Configure Logging
You do not need to create a log source to send logs from the AppSignal for Elixir integration. An "application" log source will be created automatically.
Logger Backend
You can configure the Elixir Logger to use the Appsignal.Logger.Backend
module as a backend by placing the code below in the config/runtime.exs
file:
The group
attribute describes where you are logging from and can be used in AppSignal to filter your logs. Note that you need to add the :console
shortcut for the default console logger if you also want your logs to be printed to the console.
You can also add the backend using the add_backend/2
function on your Application.start/2
callback:
Logger Handler
Instead of using an Elixir logger backend, you can configure the Erlang :logger
to use the Appsignal.Logger.Handler
module as a handler, by calling the Appsignal.Logger.Handler.add/2
function on your Application.start/2
callback:
Elixir Logger
To send logs to AppSignal without using the Elixir Logger backend, you can use one of Appsignal.Logger
's logging functions and provide it with a groupname
that defines where you are logging from. For example, if we were logging from a helper for invoicing clients:
Usage
Sending Logs
Like the Elixir/Phoenix logger class, you can define the severity level of your logs by using fatal
, error
, warning
, info
, and debug
:
You can define custom attributes to send log information that can be used when filtering and querying logs:
You can query and filter on message contents and attribute values from within the Log Management tool.
Once configured, the desired attributes will be sent to AppSignal as log_tags
, and be queryable in the AppSignal logging interface.
Logfmt
The AppSignal Logger can also parse attributes out of a Logfmt-formatted line. To do so, pass :logfmt
as the second argument:
JSON
The AppSignal Logger can also parse attributes out of a JSON-formatted line. To do so, pass :json
as the second argument:
Only primitive non-nested values (numbers, strings, booleans and null
) will be shown as log attributes. All other attributes will be discarded.
Filtering Logs
You can use the ignore_logs
configuration option to ignore log lines based on their message. See our Ignore Logs guide to learn more.
Need Help?
After configuring your Elixir application to send logs, logs should appear in AppSignal. If you are unsure about this step or AppSignal is not receiving any logs, you can always reach out for assistance. We'll help get you back on track!