My application, when encountering a database-related error, logs it as follows:
19:30:04.994 request_id=F4COjwtYrfbnTSkAABcx [debug] QUERY ERROR source="table_xyz" db=0.0ms queue=18.5ms idle=287.9ms SELECT ... FROM ... WHERE ... [1]
19:30:04.994 request_id=F4COjwtYrfbnTSkAABcx [info] Sent 500 in 81ms
19:30:04.994 request_id=F4COjwtYrfbnTSkAABcx [debug] Converted error Postgrex.Error to 500 response
This is eminently unhelpful – for one, this shouldn’t be debug level, but more importantly, it doesn’t show any information about the error itself that would allow me to fix it.
As far as I know, my logger configuration is limited to
Hey @skosch can you show the code that causes this error? This is definitely less information than I normally see if my ecto queries have an error, I’m used to seeing something like:
Repo.one from u in Sensetra.Model.User, where: u.id == "thisisntvalid"
** (Ecto.QueryError) iex:2: value `"thisisntvalid"` cannot be dumped to type :id. Or the value is incompatible or it must be interpolated (using ^) so it may be cast accordingly in query:
from u0 in Sensetra.Model.User,
where: u0.id == "thisisntvalid",
select: u0
Thank you both, this is very helpful as it’s helped me narrow the issue down a bit. Specifically, Postgrex.Error messages aren’t printed to the tmp/log/erlang.log.N files (haven’t yet tried with Ecto.QueryErrors)
When I try to query the missing column manually inside of the bin/app remote shell, I do get the error printed to my console:
** (Postgrex.Error) ERROR 42703 (undefined_column) column c0.missing_column does not exist
query: SELECT ... FROM ... WHERE ...
hint: Perhaps you meant to reference the column ...
(ecto_sql 3.10.2) lib/ecto/adapters/sql.ex:1047: Ecto.Adapters.SQL.raise_sql_call_error/1
(ecto_sql 3.10.2) lib/ecto/adapters/sql.ex:945: Ecto.Adapters.SQL.execute/6
(ecto 3.10.3) lib/ecto/repo/queryable.ex:229: Ecto.Repo.Queryable.execute/4
(ecto 3.10.3) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3
iex:3: (file)
16:39:25.739 [debug] QUERY ERROR ...
But when I hit the same by making an actual request to the app that indirectly hits a resolver function trying to access that column, all I see in tmp/log/erlang.log.1 is the unhelpful
16:39:53.436 request_id=F4Eibp9VbPR3sHQAAAWB [debug] QUERY ERROR ...
16:39:53.436 request_id=F4Eibp9VbPR3sHQAAAWB [info] Sent 500 in 53ms
16:39:53.437 request_id=F4Eibp9VbPR3sHQAAAWB [debug] Converted error Postgrex.Error to 500 response