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 in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
Hello,
I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex












First 9 of 9 Posts
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.