Koszal
How to log to stderr?
I am trying to write log messages to stderr (rather than to stdout). However, the obvious thing (device: :standard_error) seems to have no effect. In the following one-liner the log output is still written to stdout.
$ elixir -e 'require Logger; Logger.configure_backend(:console, device: :standard_error); Logger.error("why stdout?")' 2>/dev/null
20:41:11.210 [error] why stdout?
Am I missing something obvious?
I wanted to create a script that writes something to stdout and then that something is piped into another program. Hence the logger must write to stderr (rather than stdout).
Koszal
Trending in Questions
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
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated!
To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead.
Sta...
New
Hello !
We want new/edit form pages to POST/PUT to their own URL rather than the resources REST defaults (post /things, put /things/:id)...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
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
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
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
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
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
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
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #performance
- #security











First Post!
D4no0
Is this also true when running the application as a daemon?
Most Liked
dwark
There have been indeed some changes to Elixir’s Logger since v1.15.0:
Logger now uses
:logger’s default handler and refers to the logger_std_h documentation, which states:So once the
require Loggeris excuted in the one-liner, the default handler will have been added and its device cannot be changed during runtime. And looking at the actualconfiguration of the default handler:
it is indeed using stdio.
hauleth
It is possible. You just need to add additional Logger backend that will filter messages to level
:erroror higher and output tostderr.NobbZ
I took the freedom to edit some code fences in.
As this:
renders into
some text
Where the is a clickable checkbox.
Last Post!
Koszal
My goal was not to write to STDERR - rather to have the standard logger behave sensibly. (And I understand my definition of sensible may not match typical BEAM use cases).
Maybe I’ll provide more context:
I am writing a tiny app that will talk to a legacy XML API (a get-to-know Elixir/LiveView project).
I started with the XML API interface. Request payloads are rendered using EEx templates. I liked how I could pattern match to select the appropriate template and then render it injecting required values. Once I had that ready I whipped up an
.exsscript that reads key value pairs (fromSystem.argv). I could fire it off and render requests to STDOUT. The next step was piping to| curl -d@- -XPOST http://...The server complained about illegal input. After a bit of poking I realized log messages went to STDOUT rather than STDERR so I was feeding not only XML but logger output to the remote host.And hence my question about having logger write to STDOUT.