feat(logging): add method + request_path to log metadata
Every Sent log line now carries method and path so noisy traffic (probes, scrapers, redirects) is identifiable without a tracer. RemoteIp plug already sets remote_ip metadata; add method and request_path alongside it and register the extra keys with the default formatter.
This commit is contained in:
parent
cd2962687a
commit
fbbb8b2e1e
2 changed files with 7 additions and 2 deletions
|
|
@ -30,7 +30,7 @@ config :live_table,
|
||||||
# Configure Elixir's Logger
|
# Configure Elixir's Logger
|
||||||
config :logger, :default_formatter,
|
config :logger, :default_formatter,
|
||||||
format: "$time $metadata[$level] $message\n",
|
format: "$time $metadata[$level] $message\n",
|
||||||
metadata: [:request_id, :remote_ip]
|
metadata: [:request_id, :remote_ip, :method, :request_path]
|
||||||
|
|
||||||
# Configure the mailer
|
# Configure the mailer
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,12 @@ defmodule MicrowavepropWeb.Plugs.RemoteIp do
|
||||||
conn
|
conn
|
||||||
end
|
end
|
||||||
|
|
||||||
Logger.metadata(remote_ip: format_ip(conn.remote_ip))
|
Logger.metadata(
|
||||||
|
remote_ip: format_ip(conn.remote_ip),
|
||||||
|
method: conn.method,
|
||||||
|
request_path: conn.request_path
|
||||||
|
)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue