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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I really can’t miss this opportunity to scream that Elixir logs have always been one of my biggest and most frequent rants. For all that is good about this language, logs are unforgivably horrendous <img src="https://forum.elixirforum.com/images/emoji/apple/sweat_smile.png?v=15" title=":sweat_smile:" class="emoji" alt=":sweat_smile:" loading="lazy" width="20" height="20"></p>
<p>I’d love if unstructured logs did not exist, ever. There’s not a single good usecase where structured logs plus a <code>report_cb</code> doesn’t win. I always create structured logs with a report_cb that formatters can <em>optionally</em> call if they want to create a user-friendly string from the structure, noting, “user-friendly” is forever a subjective opinion and should therefore be strictly optional and never overriding the actual structure, in case someone else wants to format things differently. And even then, the “user-friendly” string <em>should not</em> replace the structured payload. But then I’ve seen many libraries that, as soon as they see a <code>report_cb</code> field, replace the entire structure with the value of that <code>report_cb</code>, so I can’t even safely add my own callbacks either.</p>
<p>I’d also be more than happy if <code>Logger</code> just did not exist at all, for once erlang’s <code>:logger</code> is better at about everything. For example, how the <code>Logger</code> is configured always bites me, it’s all <code>:logger</code> under the hood but all the configuration is slightly different so it always takes me several rounds to configure the right thing (one example, handlers other than the <code>default</code> are configured under the application and with a few keys being named differently).</p>
<p>If there’s only one thing I wish to put out there and for every one to take, ranting aside, is to <strong>use structured logging</strong>, not optionally, not sometimes, but as <strong>the only valid way</strong>. I’d even make it enforced by the library and fail compilation otherwise <img src="https://forum.elixirforum.com/images/emoji/apple/pleading_face.png?v=15" title=":pleading_face:" class="emoji" alt=":pleading_face:" loading="lazy" width="20" height="20"></p>
<p>PS: <a class="mention" href="/u/pragtob" rel="nofollow">@PragTob</a> has heard my rants so many times <img src="https://forum.elixirforum.com/images/emoji/apple/smiling_face_with_tear.png?v=15" title=":smiling_face_with_tear:" class="emoji" alt=":smiling_face_with_tear:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="391300" data-batch-url="/posts/batch_likers">
                        7
                      </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/what-do-we-do-with-logging-in-libraries/75914/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-391300" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="391300"
                     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 #11"></div>
  </section>
</div>
    <div class="postbit" id="391301" data-post-id="391301">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="videsnelson" data-post="12" data-topic="75914">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/videsnelson/48/38916_2.png" class="avatar"> videsnelson:</div>
<blockquote>
<p>I’d also be more than happy if <code>Logger</code> just did not exist at all, for once erlang’s <code>:logger</code> is better at about everything.</p>
</blockquote>
</aside>
<p>The problem is that <code>Logger</code> is older than <code>:logger</code>. If <code>:logger</code> would exist when Elixir was created, then it probably would always be just a thin wrapper around <code>:logger</code> with no separate configuration. But that was not the case.</p>
<aside class="quote no-group" data-username="videsnelson" data-post="12" data-topic="75914">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/videsnelson/48/38916_2.png" class="avatar"> videsnelson:</div>
<blockquote>
<p>it’s all <code>:logger</code> under the hood but all the configuration</p>
</blockquote>
</aside>
<p>It is now, but before 1.11 or 1.12 that was not the case (actually <code>Logger</code> was registering itself as <code>:logger</code> handler to process Erlang logs through Elixir’s backends).</p>
<p>So the whole mess is because of backward compatibility and the fact, that for a long time Erlang didn’t had any sensible logger. Before OTP 21 there was only <code>error_logger</code> module which was not general purpose logger, and if you wanted to have sensible logging in Erlang you needed to use <code>lager</code>. That is why Elixir’s <code>Logger</code> exists.</p>
<p>Another thing is that before OTP 24.2 there was no standard way to reconfigure logger while VM was already running (configuration of <code>:logger</code> happens in <code>:init</code> module that is ran before Elixir can even process its configuration). So each tool was doing the reconfiguration in their own, potentially incompatible, way.</p>
<hr>
<p>Hooray compatibility, Raymond Chen would be proud of us.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="391301" data-batch-url="/posts/batch_likers">
                        2
                      </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/what-do-we-do-with-logging-in-libraries/75914/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-391301" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="391301"
                     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 #12"></div>
  </section>
</div>
    <div class="postbit" id="391312" data-post-id="391312">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="martosaur" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/martosaur/120/38317_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  martosaur
                    <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>I’m not a fan of <code>report_cb/2</code> because of the issue grouping thing. <code>report_cb/1</code> returns a tuple that conveniently represents static and dynamic parts, but with <code>report_cb/2</code> those parts are already mushed together which makes it less useful.</p>
<p>And also there’s the part that <a class="mention" href="/u/hauleth" rel="nofollow">@hauleth</a> pointed out: with <code>report_cb/2</code> it’s your duty to preserve line length and I for one have zero idea how to do it properly <img src="https://forum.elixirforum.com/images/emoji/apple/grimacing.png?v=15" title=":grimacing:" class="emoji" alt=":grimacing:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="391312" 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/what-do-we-do-with-logging-in-libraries/75914/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-391312" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="391312"
                     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 #13"></div>
  </section>
</div>
    <div class="postbit" id="391313" data-post-id="391313">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="martosaur" data-post="14" data-topic="75914">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/martosaur/48/38317_2.png" class="avatar"> martosaur:</div>
<blockquote>
<p><code>report_cb/1</code> returns a tuple that conveniently represents static and dynamic parts, but with <code>report_cb/2</code> those parts are already mushed together which makes it less useful.</p>
</blockquote>
</aside>
<p>I’m not sure how useful this is by itself tbh. I see this purely as an implemenation detail of how <code>:logger</code> handles turning the information into text. I would never reuse those callbacks for anything else.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="391313" 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/what-do-we-do-with-logging-in-libraries/75914/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-391313" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="391313"
                     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>