<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="326367" data-post-id="326367">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="ibarch" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ibarch/120/4469_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  ibarch
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>How does your <code>payload</code> look like? It seems like console logger ignores complex data structures.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">config :logger,
  default_formatter: [
    format: "$metadata[$level] $message\n",
    metadata: [:request_id, :primitive, :complex]
  ]
</code></pre>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex&gt; require Logger
Logger
iex&gt; Logger.error("message", primitive: :foo, complex: %{foo: :bar})
primitive=foo [error] message
iex&gt; Logger.error("message", primitive: :foo, complex: :bar)
primitive=foo complex=bar [error] message
iex&gt; Logger.error("message", primitive: :foo, complex: Jason.encode!(%{foo: :bar}))
primitive=foo complex={"foo":"bar"} [error] message
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="326367" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/how-can-i-see-log-metadata-in-dev/63159/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-326367" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="326367"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #21"></div>
  </section>
</div>
    <div class="postbit" id="326368" data-post-id="326368">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimitarvp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/120/38664_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimitarvp
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>It’s a map.</p>
<p>…and OMFG, you are right. Worked with a string, and it worked when I <code>Jason.encode!</code>-d it (and also when I <code>inspect()</code>-ed it as well).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="326368" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/how-can-i-see-log-metadata-in-dev/63159/23">Post #22</a>
	                </div>
	            </div>
              <div id="likers-container-326368" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="326368"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #22"></div>
  </section>
</div>
    <div class="postbit" id="326372" data-post-id="326372">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimitarvp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/120/38664_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimitarvp
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>So to summarize, just having this in your <code>application.ex</code>:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">:logger.update_formatter_config(:default, %{metadata: [:your_metadata_key]})
</code></pre>
<p>…is enough. You don’t have to touch any of the configs in the <code>config/</code> directory at all.</p>
<p>And you can just do this after:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">Logger.info("stuff", your_metadata_key: other_stuff)
</code></pre>
<p>And it will be shown.</p>
<p>And when your metadata is not a primitive value (let’s not argue if string is a primitive, please <img src="https://forum.elixirforum.com/images/emoji/apple/smiley.png?v=15" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20">)  then you should either JSON encode it, or just <code>inspect</code> it (which turns it into a string that you can just paste in <code>iex</code> most of the time).</p>
<p>So yeah, that’s that. Huge thanks to <a class="mention" href="/u/lostkobrakai" rel="nofollow">@LostKobrakai</a> and <a class="mention" href="/u/ibarch" rel="nofollow">@ibarch</a>.</p>
<hr>
<p>I have to say that I am disappointed. This is an implicit behavior that I expected to at least have <code>Logger</code> complain about. It instead silently rejects stuff. <img src="https://forum.elixirforum.com/images/emoji/apple/confused.png?v=15" title=":confused:" class="emoji" alt=":confused:" loading="lazy" width="20" height="20"> I believe there’s a niche to be served in the Elixir ecosystem by custom <code>Logger</code> formatters, and probably an even bigger niche to just be able to configure <code>Logger</code> on maximum two places (compile + boot time config, and runtime config) and have zero surprises – which must include complaints if you pass it objects it would otherwise ignore.</p>
<p>Writing this down as one of my Elixir grievances. Might be able to tackle it OneDay™.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="326372" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/how-can-i-see-log-metadata-in-dev/63159/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-326372" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="326372"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #23"></div>
  </section>
</div>
    <div class="postbit" id="326387" data-post-id="326387">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Schultzer" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Schultzer/120/4339_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Schultzer
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Yeah, Logger has some sharp edges, but I also believe this might not be the right tool for the job, I’m a big fan of telemetry for these kind of things, even thought structured logs has come to the BEAM, seams like a lot of setup for something that should be simpler, but there might be good reasons for it.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="326387" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/how-can-i-see-log-metadata-in-dev/63159/25">Post #24</a>
	                </div>
	            </div>
              <div id="likers-container-326387" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="326387"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #24"></div>
  </section>
</div>
    <div class="postbit" id="326388" data-post-id="326388">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimitarvp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/120/38664_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimitarvp
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Same here for OTel, that’s going to be my next step, I even experimented with OpenObserve in my Golang and Rust work and it worked amazingly well there – logs, metrics and telemetry, all included – so I’ll do it with Elixir next.</p>
<p>Indeed <code>Logger</code> itself seems like it’s not getting the love it deserves and to me it looks more like a thin wrapper over Erlang’s <code>:logger</code> that does not attempt to fix its sharp edges and just carries them over.</p>
<p>Which is fine but it’s IMO dooming it to obscurity.</p>
<aside class="quote no-group" data-username="Schultzer" data-post="25" data-topic="63159">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/schultzer/48/4339_2.png" class="avatar"> Schultzer:</div>
<blockquote>
<p>even thought structured logs has come to the BEAM, seams like a lot of setup for something that should be simpler, but there might be good reasons for it.</p>
</blockquote>
</aside>
<p>Good reasons or not, technology should be ergonomic. If it’s not then it’s not living up to its potential. And I quite agree with your “a lot of setup for something that should be simpler”, yep.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="326388" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/how-can-i-see-log-metadata-in-dev/63159/26">Post #25</a>
	                </div>
	            </div>
              <div id="likers-container-326388" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="326388"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>