Replies: 5 comments 1 reply
-
According to the documentation https://logging.apache.org/log4j/2.x/manual/configuration.html the credentials are specified with the log4j2.Configuration.username and log4j2.Configuration.password properties. |
Beta Was this translation helpful? Give feedback.
-
Hi @luidoc,
The The current documentation will be replaced with a more navigable version soon: see Transport Security for all the Log4j Configuration properties involved into establishing a secure connection. |
Beta Was this translation helpful? Give feedback.
-
We use this configuration in our bootstrap.yml file to connect to SCC for both the application config and the logging config.
Note that this configuration will depend on how your SCC server's search path is configured. Ours is just "*" so every directory would be searched. We place the logging config files in the root directory. Using * means you can never have duplicate files even in subdirectories or things will get confusing. |
Beta Was this translation helpful? Give feedback.
-
The final configuration, which works in the example I have provided, is as follows:
I've added the "allowedProtocols" property, to allow using http in this simple example, since by default only https is enabled. |
Beta Was this translation helpful? Give feedback.
-
The configuration given to resolve this issue works with Spring Boot 2, but not with Spring Boot 3.
Using Spring Boot 3 it seems that Log4j2 configuration is done before the decryption of the property spring.cloud.config.password, therefore the "Config Server" service responds an http 401 error. |
Beta Was this translation helpful? Give feedback.
-
Versions:
spring-boot-starter-parent : 3.3.2
spring-cloud-dependencies: 2023.0.3
jdk: 21
Details:
My "Spring Cloud Config Server" has a security configuration applied, therefore authentication is required to access the service.
The source code can be seen at https://github.com/luidoc/demo-config-server-native.git
On the other hand, I have a sample application that uses the "Spring Cloud Config Server" service, both to obtain its configuration file and to obtain the log4j2 configuration file (log4j2-spring.xml).
The source code can be seen at https://github.com/luidoc/config-server-client.git
Below I show the bootstrap.yml configuration file:
When running the sample application, it fails to obtain the log4j2 configuration file from the "Config Server" service, resulting in an http 401 error.
The error trace can be seen below:
On the other hand, I can perfectly obtain the configuration file using curl.
Is it possible to provide Log4j2 with credentials to access the web service and download the configuration file?
Sample
Config Server: https://github.com/luidoc/demo-config-server-native.git
Demo application: https://github.com/luidoc/config-server-client.git
Beta Was this translation helpful? Give feedback.
All reactions