title: Spring Logging SLF4J binded to Log4J
body: <p>I'm trying to configure my SpringMVC application to log using SLF4J instead of vanilla commons-logging.</p>
  
  <p>I'm totally stuck, my file doesn't log anything although if I debug the code the expression <code>if (log.isDebugEnabled()) {</code> is evaluated to true.</p>
  
  <p>What I'm doing wrong?</p>
  
  <p>This is my config:</p>
  
  <p><strong>My pom.xml</strong></p>
  
  <pre><code>&lt;!-- Logging --&gt;
  &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
          &lt;version&gt;${org.springframework-version}&lt;/version&gt;
          &lt;exclusions&gt;
              &lt;!-- Exclude Commons Logging in favor of SLF4j --&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;commons-logging&lt;/groupId&gt;
                  &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;jcl-over-slf4j&lt;/artifactId&gt;
          &lt;version&gt;${org.slf4j-version}&lt;/version&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
          &lt;version&gt;${org.slf4j-version}&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;${org.slf4j-version}&lt;/version&gt;
          &lt;scope&gt;runtime&lt;/scope&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.17&lt;/version&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p><strong>My log4j.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN"       "log4j.dtd"&gt;
  &lt;log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"&gt;
  
  &lt;!-- Appenders --&gt;
  &lt;appender name="console" class="org.apache.log4j.ConsoleAppender"&gt;
      &lt;param name="Target" value="System.out" /&gt;
      &lt;layout class="org.apache.log4j.PatternLayout"&gt;
          &lt;param name="ConversionPattern" value="%-5p: %c - %m%n" /&gt;
      &lt;/layout&gt;
  &lt;/appender&gt;
  
  &lt;appender name="fileAppender" class="org.apache.log4j.FileAppender"&gt;
      &lt;param name="Threshold" value="ALL" /&gt;
      &lt;param name="File" value="${catalina.home}/logs/workcontrol.log" /&gt;
      &lt;layout class="org.apache.log4j.PatternLayout"&gt;
          &lt;param name="ConversionPattern" value="%d  %-5p  [%c{1}] %m %n" /&gt;
      &lt;/layout&gt;
  &lt;/appender&gt;
  
  &lt;!-- Application Loggers --&gt;
  &lt;logger name="es.jumtech.workcontrol"&gt;
      &lt;level value="ALL" /&gt;
      &lt;appender-ref ref="fileAppender" /&gt;
  &lt;/logger&gt;
  
  &lt;!-- 3rdparty Loggers --&gt;
  &lt;logger name="org.springframework.core"&gt;
      &lt;level value="info" /&gt;
  &lt;/logger&gt;
  
  &lt;logger name="org.springframework.beans"&gt;
      &lt;level value="info" /&gt;
  &lt;/logger&gt;
  
  &lt;logger name="org.springframework.context"&gt;
      &lt;level value="info" /&gt;
  &lt;/logger&gt;
  
  &lt;logger name="org.springframework.web"&gt;
      &lt;level value="info" /&gt;
  &lt;/logger&gt;
  
  &lt;logger name="org.hibernate"&gt;
      &lt;level value="info" /&gt;
  &lt;/logger&gt;
  
  &lt;!-- Root Logger --&gt;
  &lt;root&gt;
      &lt;priority value="ERROR" /&gt;
      &lt;appender-ref ref="console" /&gt;
  &lt;/root&gt;
  
  &lt;/log4j:configuration&gt;
  </code></pre>
  
  <p>And my Java Class which should log:</p>
  
  <pre><code>package es.jumtech.workcontrol.persistence.initial;
  
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.context.ApplicationListener;
  import org.springframework.context.event.ContextRefreshedEvent;
  import org.springframework.stereotype.Component;
  import org.springframework.transaction.annotation.Transactional;
  
  import es.jumtech.workcontrol.persistence.dao.ProfileDAO;
  import es.jumtech.workcontrol.persistence.dao.RoleDAO;
  import es.jumtech.workcontrol.persistence.entity.Profile;
  import es.jumtech.workcontrol.persistence.entity.Role;
  
  @Component
  public class DataSeeder implements ApplicationListener&lt;ContextRefreshedEvent&gt; {
  
  @Autowired
  private RoleDAO roleDAO;
  
  @Autowired
  private ProfileDAO profileDAO;
  
  private static final Logger log = LoggerFactory.getLogger(DataSeeder.class);
  
  @Override
  @Transactional(readOnly = false)
  public void onApplicationEvent(ContextRefreshedEvent event) {
      // Se inicializan los roles
      loadRoles();
  
      // Se inicializan los perfiles
      loadProfiles();
  }
  
  private void loadRoles() {
      if (log.isDebugEnabled()) {
          log.debug("Se comprueba si existen los roles");
      }
  
      Role roleBoss = roleDAO.getRoleByName(Role.BOSS);
      if (roleBoss == null) {
          log.error("No existe el rol ROLE_BOSS, se crea");
          roleBoss = new Role();
          roleBoss.setRole(Role.BOSS);
          roleDAO.createRole(roleBoss);
      }
  
      Role roleAdmin = roleDAO.getRoleByName(Role.ADMIN);
      if (roleAdmin == null) {
          log.error("No existe el rol ROLE_ADMIN, se crea");
          roleAdmin = new Role();
          roleAdmin.setRole(Role.ADMIN);
          roleDAO.createRole(roleAdmin);
      }
  
      Role roleWorker = roleDAO.getRoleByName(Role.WORKER);
      if (roleWorker == null) {
          log.error("No existe el rol ROLE_WORKER, se crea");
          roleWorker = new Role();
          roleWorker.setRole(Role.WORKER);
          roleDAO.createRole(roleWorker);
      }
  }
  
  private void loadProfiles() {
      log.error("Se comprueba si existen los perfiles");
  
      Profile deliveryProfile = profileDAO.getProfileByName("Repartidor");
      if (deliveryProfile == null) {
          log.error("No existe el perfil Repartidor, se crea");
          deliveryProfile = new Profile();
          deliveryProfile.setProfile("Repartidor");
          profileDAO.createProfile(deliveryProfile);
      }
  
      Profile comercialProfile = profileDAO
              .getProfileByName("Agente Comercial");
      if (comercialProfile == null) {
          log.error("No existe el perfil Agente Comercial, se crea");
          comercialProfile = new Profile();
          comercialProfile.setProfile("Agente Comercial");
          profileDAO.createProfile(comercialProfile);
      }
  
      Profile officeProfile = profileDAO.getProfileByName("Oficinista");
      if (officeProfile == null) {
          log.error("No existe el perfil Oficinista, se crea");
          officeProfile = new Profile();
          officeProfile.setProfile("Oficinista");
          profileDAO.createProfile(officeProfile);
      }
  
  }
  }
  </code></pre>
  
  <p><strong>SOLUTION</strong></p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-solr&lt;/artifactId&gt;
          &lt;version&gt;1.1.4.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>As @mp911de pointed, this dependency was importing the Logback library which also implements SLFJ4, and the logger that was returning:</p>
  
  <p><code>private static final Logger log = LoggerFactory.getLogger(DataSeeder.class);</code></p>
  
  <p>Was instance of ch.qos.logback.classic.Logger instead of org.slf4j.impl.Log4jLoggerAdapter</p>
  
  <p>Thanks in advance,
  Diego.</p>