Spring-Boot logging with log4j2?

后端 未结 3 1659
挽巷
挽巷 2021-02-07 08:26

I\'m using spring-boot-starter, and would like to configure log4j2.xml to log asynchron + different content to different logfiles.

I created th

3条回答
  •  逝去的感伤
    2021-02-07 08:44

    Try this:

    1. Exclude spring-boot-starter-logging e.g.

      
          org.springframework.boot
          spring-boot-starter
          
              
                  org.springframework.boot
                  spring-boot-starter-logging
              
          
      
      
    2. Add dependencies for your logging interface e.g. slf4j

      
          org.apache.logging.log4j
          log4j-slf4j-impl
          2.0.2
      
      
    3. Add other logging implementations pointing to chosen logging interface e.g.

      
          org.slf4j
          jcl-over-slf4j
      
      
          org.slf4j
          jul-to-slf4j
      
      
          org.slf4j
          log4j-over-slf4j
      
      
    4. Add your target logging implementation e.g.

      
          org.apache.logging.log4j
          log4j-api
          2.0.2
      
      
          org.apache.logging.log4j
          log4j-core
          2.0.2
      
      

    And it should work.

提交回复
热议问题