I noticed that the file field is coming out as an array of numbers instead of a string in our JSON logs (also applies to the default formatter btw).
My first instinct was to fix this in the formatter, which is logstash_logger_formatter in our case. After digging a little bit deeper I saw that Logger
specifically converts the file to a charlist in compile_time_application_and_file/1
.
defp compile_time_application_and_file(%{file: file}) do
if app = Application.get_env(:logger, :compile_time_application) do
{[application: app], file |> Path.relative_to_cwd() |> String.to_charlist()}
else
{[], String.to_charlist(file)}
end
end
Can anyone help me understand why it must be a charlist?