Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-3405

LookupSupport Spring Boot without Cloud BusBridge

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.17.1
    • 2.17.2
    • Boot
    • None

    Description

      It would be great if Support Spring Boot https://logging.apache.org/log4j/2.x/manual/lookups.html like
      ${spring:spring.application.name}
      could be supported without requiring a cloud bus spring configuration. Thus being usable in normal projects.

       

      What happens in non-cloud projects, if you include the `log4j-spring-cloud-config-client` dependency, is the following error:

      {}***************************
      APPLICATION FAILED TO START
      ***************************Description:Parameter 1 of method busRemoteApplicationEventListener in org.springframework.cloud.bus.BusAutoConfiguration required a bean of type 'org.springframework.cloud.bus.BusBridge' that could not be found.
      {{}}

      It would be great having the ability to inject `application.properties` parameters from Spring in general.

       

      I tried excluding the cloud dependency as follows:

      <dependency>
         <groupId>org.apache.logging.log4j</groupId>
         <artifactId>log4j-spring-cloud-config-client</artifactId>
         <version>2.17.1</version>
        <exclusions>
        <exclusion>
         <groupId>org.springframework.cloud</groupId>
         <artifactId>spring-cloud-bus</artifactId>
        </exclusion>
       </exclusions>
      </dependency>

       

      spring.cloud.config.enabled=false

      spring.cloud.compatibility-verifier.enabled=false

      spring.application.name=foo

       

      <RollingRandomAccessFile name="APP" fileName="${path}/${spring:spring.application.name}.logs" filePattern="${path}/archive/${spring:spring.application.name}.log.gz">

       

      This works to some degree. BUT log4j creates 2 files in this process:

      a) ${spring:spring.application.name}.logs

      b) foo.logs

       

      Somehow the property is resolved a bit too late at some stage.

      Attachments

        Activity

          People

            Unassigned Unassigned
            membersound member sound
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: