dmitriid
{:ecto_sql, "~> 3.4"},
{:phoenix, "~> 1.5.8"},
{:phoenix_ecto, "~> 4.1"},
{:myxql, "~> 0.4.0"},
Currently Ecto is driving me crazy in development by outputting hundreds of lines of [debug] code into the console (running iex -S mix phx.server). [1] If I put log: :error into adapter config, this only makes those same hundreds of lines to output with [error]
[2]
I don’t want to disable ecto logging entirely though. If there’s an error happening, I want Ecto to log the error. I don’t think the docs cover how to do it. Do I somehow configure Telemetry to achieve what I need?
Send help! ![]()
[1]
[2]
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m aware of 2 such projects, are there others?
git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
Hello folks!
So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
How Can I Optimise Compile Time Dependencies
I have been building an elixir application for about 2 years now. Many modules and files ha...
New
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
Other Trending Topics
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with.
But I don’t use it anymore.
Serverless was the promis...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex












Showing Posts 1 to 9- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
RudManusachi
Those logs are just printing “query”. If error happens before query executed - you’ll see the error logged. If error happens after query executed - you’ll see both
[deug] QUERY...and the error. You could setlog: falseand only errors, are supposed to be logged anyway.John-Goff
You should set your log level in your dev.exs file. See Logger — Logger v1.12.3 and Logger — Logger v1.12.3 for more info.
03juan
Take a look at the application configuration section of the Logger docs where it describes the
:compile_time_purge_matchingoption. Find the corresponding Ecto function that’s printing the debug log, then just silence that module + function withlevel_lower_than: :infoThis is the beauty of Elixir separation of concerns that I’m still learning and coming across these great examples: instead of trying to cater for many different logging requirements by trying to configure Ecto, reconfigure at the Logger side!
03juan
Just tried my own advice and this unfortunately won’t work!
Docs say that
So I first modified my logger config to find the logging function:
That resulted in
But the
ecto_sqllibrary at line 938 invokes Logger.log/3 which warns thatI added an explicit
:debugcase option to thelog/4source code in my deps folder and recompiled as instructed withmix deps.compile ecto_sqlbut it’s still logging?config.exsHopefully someone with more experience can provide some insight
dmitriid
Thank you all for suggestions! I haven’t had the time to try them all out, I will try tomorrow!
KristerV
This has been frustrating me since I started with Elixir years ago. Kind of a crazy oversight imo. It seems that in production all SQL logs are hidden by default and that includes errors.
I’ve heard this again many times and it just doesn’t seem to be the case.
fuelen
The first thing that comes to my mind is to disable default ecto logs and provide custom handler for
[:myapp, :repo, :query]telemetry events.dmitriid
Logger configuration affects the entire application.
In this case I only want to reduce verbosity of Ecto. Because I may have my own debug calls that I want to see in the console.
dmitriid
Ok, this works, at least for me, and in my particular case.
Given
log: falsein the config, I made a deliberate error in a query (iddinstead ofid):Ecto failed and printed the following error:
No other debug logs. At this point this probably covers 99.999% of my needs.
@KristerV Give it a try. Quite possible if it wasn’t working for you it was a bug that was solved at one point.