Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make Jersey to use SLF4J instead of JUL?
    primarykey
    data
    text
    <p>I've found <a href="http://blog.cn-consult.dk/2009/03/bridging-javautillogging-to-slf4j.html" rel="noreferrer">a useful article</a> that explains how to make Jersey to use SLF4J instead of JUL. Now my unit test looks like (and it works perfectly):</p> <pre><code>public class FooTest extends JerseyTest { @BeforeClass public static void initLogger() { java.util.logging.Logger rootLogger = java.util.logging.LogManager.getLogManager().getLogger(""); java.util.logging.Handler[] handlers = rootLogger.getHandlers(); for (int i = 0; i &lt; handlers.length; i++) { rootLogger.removeHandler(handlers[i]); } org.slf4j.bridge.SLF4JBridgeHandler.install(); } public FooTest() { super("com.XXX"); } @Test public void testSomething() throws Exception { // ... } } </code></pre> <p>My <code>pom.xml</code> includes these dependencies:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;org.slf4j&lt;/groupId&gt; &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt; &lt;version&gt;1.6.1&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.slf4j&lt;/groupId&gt; &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt; &lt;version&gt;1.6.1&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.slf4j&lt;/groupId&gt; &lt;artifactId&gt;jul-to-slf4j&lt;/artifactId&gt; &lt;version&gt;1.6.1&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;log4j&lt;/groupId&gt; &lt;artifactId&gt;log4j&lt;/artifactId&gt; &lt;version&gt;1.2.16&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>It works perfectly, but I don't want to make the same configuration in every unit test. It's an obvious code duplication, which I would like to avoid. How can I do this more effectively?</p> <p>ps. Maybe it's not possible to optimize the code above and I'm doing the best I can?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload