Git Product home page Git Product logo

Comments (3)

SebHeuze avatar SebHeuze commented on May 18, 2024 1

@ppkarwasz I have the same problem since I upgraded from 2.17.2 to 2.19 (Spring boot 2.3.9)
I don't need two log4j files or arbiters to make it work in 2.17.2

But since 2.18 it stopped working because of the new way to load LoggingSystemFactory (spring.factories)
I still don't understand why spring.factories are not loaded

EDIT : It don't work because LoggingSystemFactory does not exist before Spring 2.4, the documentation mention that the lib require Spring boot 2.0.3 or 2.1.1, which is outdated since Log4J 2.18

from logging-log4j2.

ppkarwasz avatar ppkarwasz commented on May 18, 2024

@schotten,

Logging in a Spring Boot application is configured at least twice:

  • when the SpringApplication class is loaded (that is what you see in your stacktrace). This process is described in automatic configuration and does not have access to Spring's environment (that didn't start yet),
  • after the ApplicationEnvironmentPreparedEvent is fired (cf. lifecycle of a Spring Boot application). This process is specific to Spring Boot, has access to Spring's environment and uses the log4j2-spring.xml file (falling back on log4j2.xml if such a file does not exist).

If you want to use Spring's enviroment to configure your logging system you have to options:

  1. Create two files: log4j2.xml and log4j2-spring.xml. The first one will be used during the bootstrap phase of your application and can not use Spring's environment. The second one will be used, when your application is up and running.
  2. Stick to a single configuration file and use arbiters to provide multiple versions of your "solver-service" appender:
<Select>
    <SpringProfile name="dev">
        <File name="solver-service" fileName="${spring:log4j.solver.service.path}" append="false">
            <EcsLayout serviceName="${spring:log4j.solver.service.name}" serviceVersion="${spring:log4j.solver.service.version}"  serviceEnvironment="${spring:log4j.solver.service.enviroment}"/>
        </File>
    </SpringProfile>
    <DefaultArbiter>
        <Null name="solver-service"/>
    </DefaultArbiter>
</Select>

from logging-log4j2.

ppkarwasz avatar ppkarwasz commented on May 18, 2024

I am closing this for lack of activity. I think that:

Fill free to reopen the issue.

from logging-log4j2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.