-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide compatibility or replace the need for the Log4j-Spring-Boot Module #28909
Comments
I‘m expecting Spring Lookup. |
See also the discussion in #22149 (comment) |
@rgoers and @wilkinsona: I would like to add my two cents on how to solve this issue and the recursive dependency mentioned in #22149. The Therefore without loosing backward compatibility one might:
|
Log4j2's PR #777 could be used to easily disable |
Thanks for the suggestions, @ppkarwasz. Unfortunately, they won't really address my concerns about circular dependencies as we prefer not to have any dependency cycles, even when it's only in test code. Even if we addressed the test code, we'd still be left with Spring Framework's |
Hi all. |
The Spring lookup was integrated into Spring Boot 3.x. For Spring Boot 2.x you need to add |
I am going to close this as my PR was integrated into Spring Boot 3. |
Spring Boot 2.6.0 added support for Log4j2 Composite Configurations. Log4j's log4j-spring-boot module also provides support for this but in a different manner since prior to 2.6.0 Spring Boot only allowed a single property to identify the logging configuration files. But log4j-spring-boot also allows these files to be stored in a Spring Cloud Configuration server instance with access via HTTP(S) even if the access is password protected. Spring Boot does not so anyone looking for that support will have to forego Spring Boot's support and use log4j-spring-boot instead. Log4j also allows SSL configuration to be provided although this is probably not very important in a Spring Boot environment where the SSL/TLS configuration for the JVM is probably OK.
log4j-spring-boot also provides
Spring Lookup
The Spring Lookup allows configuration files to reference properties defined in Spring configuration files from a Log4j configuration file. For example:
<property name="applicationName">${spring:spring.application.name}</property>
would set the Log4j applicationName property to the value of spring.application.name set in the Spring configuration. Users can then do things like:
Spring Property Source
Log4j uses property sources when resolving properties it uses internally. This support allows most of Log4j’s System Properties to be specified in the Spring Configuration. However, some properties that are only referenced during the first Log4j initialization, such as the property Log4j uses to allow the default Log4j implementation to be chosen, would not be available.
Spring Profile Arbiter
New with Log4j 2.15.0 are "Arbiters" which are conditionals that can cause a portion of the Log4j configuration to be included or excluded. log4j-spring-boot provides an Arbiter that allows a Spring profile value to be used for this purpose. Below is an example:
To implement these features Log4j had to extend Spring's Log4j2LoggingSystem. This is unfortunate as it means Log4j may need to be modified to support new versions that add new methods or features as 2.6.0 did. Log4j will now need to override the new loadConfiguration method that accepts a list of override names so that authentication support can be added to the new way of specifying override files.
Finally, it is confusing to users to have to use log4j-spring-boot to get features that enhance Spring Boot's integration with Log4j.
The text was updated successfully, but these errors were encountered: