title: Caused by: org.apache.logging.log4j.LoggingException: log4j-slf4j-impl cannot be present with log4j-to-slf4j
body: <p>In my <strong>Spring boot 2</strong> project:</p>
  
  <p>In <code>build.gradle</code>:</p>
  
  <pre><code>dependencies {
      implementation 'com.google.code.gson:gson:2.7'
      implementation 'com.h2database:h2'
      implementation 'javax.servlet:jstl:1.2'
      implementation 'org.springframework.boot:spring-boot-devtools'
      implementation('org.springframework.boot:spring-boot-starter') {
          exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
      }
      implementation 'org.springframework.boot:spring-boot-starter-actuator'
      implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
      implementation 'org.springframework.boot:spring-boot-starter-log4j2'
      implementation 'org.springframework.boot:spring-boot-starter-jdbc'
      implementation 'org.springframework.boot:spring-boot-starter-security'
      implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
      implementation "org.springframework.boot:spring-boot-starter-web"
  
      testImplementation('org.springframework.boot:spring-boot-starter-test') {
          exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
      }
  
      testImplementation 'org.junit.jupiter:junit-jupiter:5.5.2'
  }
  </code></pre>
  
  <p>In <code>src/resources/log4j2.xml</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"&gt;
  
  &lt;log4j:configuration debug="true" xmlns:log4j="http://jakarta.apache.org/log4j/"&gt;
  
      &lt;appender name="Console"
                class="org.apache.log4j.ConsoleAppender"&gt;
          &lt;layout class="org.apache.log4j.PatternLayout"&gt;
              &lt;!-- l, L, M - is extremely slow. It's use should be avoided unless execution
                  speed is not an issue. --&gt;
              &lt;param name="ConversionPattern"
                     value="%p: %d{dd.MM.yyyy HH:mm:ss.SSS} %l %n    %m%n"/&gt;
          &lt;/layout&gt;
      &lt;/appender&gt;
  
      &lt;appender name="File"
                class="org.apache.log4j.DailyRollingFileAppender"&gt;
          &lt;param name="Encoding" value="UTF-8"/&gt;
          &lt;param name="File" value="logs/trace.log"/&gt;
          &lt;param name="Append" value="true"/&gt;
          &lt;layout class="org.apache.log4j.PatternLayout"&gt;
              &lt;!-- l, L, M - is extremely slow. It's use should be avoided unless execution
                  speed is not an issue. --&gt;
              &lt;param name="ConversionPattern"
                     value="%p: %d{dd.MM.yyyy HH:mm:ss.SSS} %l %n    %m%n"/&gt;
          &lt;/layout&gt;
      &lt;/appender&gt;
  
      &lt;!-- Application Loggers --&gt;
      &lt;logger name="com.journaldev.spring"&gt;
          &lt;level value="info"/&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.hibernate"&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;!-- The root category is used for all loggers unless a more specific logger
          matches. If none of the loggers are assigned a level, then all loggers inherit
          the level of the root logger which is set to DEBUG by default --&gt;
      &lt;root&gt;
          &lt;level value="ALL"/&gt;
          &lt;appender-ref ref="Console"/&gt;
          &lt;!-- &lt;appender-ref ref="File" /&gt; --&gt;
      &lt;/root&gt;
  
  &lt;/log4j:configuration&gt;
  </code></pre>
  
  <p>In my controller:</p>
  
  <pre><code>import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.web.bind.annotation.GetMapping;
  
  @Controller
  public class CategoryController {
      private CategoryRepository categoryRepository;
  
      private static Logger logger = LoggerFactory.getLogger(CategoryController.class);
  
   @GetMapping("/categories")
      public String getCategories(Model model) {
          logger.debug("getCategories&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;");
          model.addAttribute("categoryList", this.categoryRepository.findAll());
          return "categories/category_list";
      }
  }
  </code></pre>
  
  <p>But when I start project I get error:</p>
  
  <blockquote>
    <p>Caused by: org.apache.logging.log4j.LoggingException: log4j-slf4j-impl
    cannot be present with log4j-to-slf4j</p>
  </blockquote>