<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Matthias Langer</title>
    <description>The latest articles on DEV Community by Matthias Langer (@mlangc).</description>
    <link>https://dev.to/mlangc</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3368294%2F93ceb714-3de6-4e67-bc80-c6605efc92c5.png</url>
      <title>DEV Community: Matthias Langer</title>
      <link>https://dev.to/mlangc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mlangc"/>
    <language>en</language>
    <item>
      <title>more-log4j2-2.1.0 with improved test support has been released</title>
      <dc:creator>Matthias Langer</dc:creator>
      <pubDate>Fri, 23 Jan 2026 16:09:16 +0000</pubDate>
      <link>https://dev.to/mlangc/more-log4j2-210-with-improved-test-support-has-been-released-2n62</link>
      <guid>https://dev.to/mlangc/more-log4j2-210-with-improved-test-support-has-been-released-2n62</guid>
      <description>&lt;p&gt;I have invested quite some time writing an asynchronous HTTP appender, that can be used to push logs to various observability platforms. &lt;a href="https://github.com/mlangc/more-log4j2?tab=readme-ov-file#async-httpappender" rel="noopener noreferrer"&gt;This appender&lt;/a&gt; was released under the Apache License as part  of &lt;a href="https://github.com/mlangc/more-log4j2?tab=readme-ov-file#async-httpappender" rel="noopener noreferrer"&gt;more-log4j2-2.0.0&lt;/a&gt; about 2 weeks ago. One of my personal use cases is ingesting logs from locally executed unit tests. And while that works nicely with the previous release already, I discovered two problems, that are addressed in &lt;a href="https://github.com/mlangc/more-log4j2" rel="noopener noreferrer"&gt;more-log4j2-2.1.0&lt;/a&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Some of you might use the &lt;a href="https://github.com/Hakky54/log-captor" rel="noopener noreferrer"&gt;io.github.hakky54:logcaptor&lt;/a&gt; library. This library is very helpful if you    want to have assertions on your log output, however, there is a catch: The library    &lt;a href="https://github.com/Hakky54/log-captor?tab=readme-ov-file#using-log-captor-alongside-with-other-logging-libraries" rel="noopener noreferrer"&gt;relies on logback&lt;/a&gt;, and thereby blocks you from using &lt;code&gt;more-log4j2&lt;/code&gt; for your tests.  &lt;a href="https://central.sonatype.com/artifact/com.github.mlangc/more-log4j2/2.1.0" rel="noopener noreferrer"&gt;more-log4j2-2.1.0&lt;/a&gt; addresses this problem  &lt;a href="https://github.com/mlangc/more-log4j2?tab=readme-ov-file#Capturing-Appender" rel="noopener noreferrer"&gt;by reimplementing the LogCaptor API&lt;/a&gt; for log4j2. A few small tweaks to your &lt;code&gt;log4j2-test.xml&lt;/code&gt; and  switching your imports from &lt;code&gt;nl.altindag.log.LogCaptor&lt;/code&gt; to &lt;code&gt;com.github.mlangc.more.log4j2.captor.LogCaptor&lt;/code&gt; should be enough. In some cases trivial refactorings might be necessary, since I didn't clone the &lt;a href="https://github.com/Hakky54/log-captor/tree/master/src/main/java/nl/altindag/log/model" rel="noopener noreferrer"&gt;nl.altindag.log.model&lt;/a&gt; classes, but choose to expose the log4j2 APIs directly.&lt;/li&gt;
&lt;li&gt;Spring Boot users might stumble over logs being dropped on test shutdown. Spring Boot normally takes care of shutting down the logger context, and therefore installs &lt;a href="https://docs.spring.io/spring-boot/api/java/org/springframework/boot/logging/log4j2/SpringBootPropertySource.html" rel="noopener noreferrer"&gt;a property source&lt;/a&gt;, that unconditionally disables the &lt;a href="https://logging.apache.org/log4j/2.x/manual/systemproperties.html#log4j2.shutdownHookEnabled" rel="noopener noreferrer"&gt;log4j2 shutdown-hook&lt;/a&gt;. Unfortunately this affects also tests that are completely independent of Spring, since the &lt;a href="https://docs.spring.io/spring-boot/api/java/org/springframework/boot/logging/log4j2/SpringBootPropertySource.html" rel="noopener noreferrer"&gt;SpringBootPropertySource&lt;/a&gt; is installed automatically as soon as it's on the classpath. Once installed, setting &lt;a href="https://logging.apache.org/log4j/2.x/manual/systemproperties.html#log4j2.shutdownHookEnabled" rel="noopener noreferrer"&gt;log4j2.shutdownHookEnabled&lt;/a&gt; has no effect, since the &lt;code&gt;SpringBootPropertySource&lt;/code&gt; gives itself &lt;a href="https://github.com/spring-projects/spring-boot/blob/27e3ddc7fba34ab9f6bb1cd2e5209fe5d1e42765/core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/SpringBootPropertySource.java#L53" rel="noopener noreferrer"&gt;a higher priority&lt;/a&gt; than the &lt;a href="https://github.com/apache/logging-log4j2/blob/rel/2.25.3/log4j-api/src/main/java/org/apache/logging/log4j/util/SystemPropertiesPropertySource.java#L38" rel="noopener noreferrer"&gt;SystemPropertiesPropertySource&lt;/a&gt; and the &lt;a href="https://github.com/apache/logging-log4j2/blob/2.x/log4j-api/src/main/java/org/apache/logging/log4j/util/EnvironmentPropertySource.java#L40" rel="noopener noreferrer"&gt;EnvironmentPropertySource&lt;/a&gt; which are shipped with &lt;code&gt;log4j2&lt;/code&gt;. The new &lt;a href="https://github.com/mlangc/more-log4j2?tab=readme-ov-file#more-log4j2-junit" rel="noopener noreferrer"&gt;more-log4j2-junit-2.1.0 module&lt;/a&gt; addresses this problem for Junit tests, by providing a &lt;a href="https://docs.junit.org/6.0.0/api/org.junit.platform.launcher/org/junit/platform/launcher/TestExecutionListener.html" rel="noopener noreferrer"&gt;TestExecutionListener&lt;/a&gt; that flushes &lt;code&gt;AsyncHttpAppender&lt;/code&gt; instances when tests
have finished. This listener is installed automatically once on the runtime classpath.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Any feedback is highly appreciated.&lt;/p&gt;

</description>
      <category>java</category>
      <category>log4j2</category>
      <category>testing</category>
      <category>unittest</category>
    </item>
  </channel>
</rss>
