title: Jboss logging to slf4j/log4j2 with Keycloak
body: <p>I have a Keycloak EAR module, deployed on Keycloak 11.0. In my EAR module I want to use log4j2 logging library with slf4j. I successfully accomplished this by adding the following dependencies in the pom directly: <code>log4j-slf4j-impl</code>, <code>log4j-api</code> &amp; <code>log4j-core</code>.</p>
  <p>Wildfly logging dependencies are excluded by setting <code>add-logging-api-dependencies</code> to <code>false</code>. <code>log4j2.xml</code> is specified outside the packaged EAR and is referenced with <code>log4j.configurationFile</code> system property.</p>
  <p>Now the problem. I also want Keycloak to use log4j2 but I cannot get this to work. Keycloak is using Jboss Logging wrapper which always picks up <code>JbossLogManager</code> no matter which logging provider I set - I always get either <code>ClassNotFoundException</code> or <code>NoClassDefFoundError</code>.</p>
  <p>I realize there is a classpath problem but I am out of ideas at this point. I tried creating <code>log4j-slf4j-impl</code>, <code>log4j-api</code> &amp; <code>log4j-core</code> Wildfly modules with the following command but I still get the same error.</p>
  <pre><code>./jboss-cli.sh --command=&quot;module add --name=org.apache.logging.log4j.log4j-api --resources=/Users/jernej/log4j-api-2.13.3.jar&quot;
  </code></pre>
  <p>If I understand correctly, log4j2 should be in the classpath on Wildfly startup (when searching for <code>LoggerProvider</code>)  and Jboss Logging <code>findProvider</code> method should return <code>Log4j2LoggerProvider</code> if modules are correctly added? How can I accomplished this?</p>
  <p>Suppose I want to use log4j2 appender, located in separate library. If I add this library as a Wildfly module this log4j2 appender can then be used by other deployments as well - e.g. keycloak-server.war?</p>