Log4j Spring Cloud ConfigurationThis module allows logging configuration files to be dynamically updated when new versions are available in Spring Cloud Configuration. OverviewSpring Boot applications initialize logging 3 times. 1. SpringApplication declares a Logger. This Logger will be initialized using Log4j’s “normal” mechanisms. Thus a system property named log4j2.configurationFile will be checked to see if a specific configuration file has been provided, otherwise it will search for a configuration file on the classpath. The property may also be declare in log4j2.component.properties. UsageLog4j configuration files that specify a monitor interval of greater than zero will use polling to determine whether the configuration has been updated. If the monitor interval is zero then Log4j will listen for notifications from Spring Cloud Config and will check for configuration changes each time an event is generated. If the monitor interval is less than zero Log4j will not check for changes to the logging configuration. When referencing a configuration located in Spring Cloud Config the configuration should be referenced similar to log4j.configurationFile=http://host.docker.internal:8888/ConfigService/sampleapp/default/master/log4j2.xml When running in a docker container host.docker.internal may be used as the domain name to access an application running on the same hose outside of the docker container. Note that in accordance with Spring Cloud Config practices but the application, profile, and label should be specified in the url. The Spring Cloud Config support also allows connections using TLS and/or basic authentication. When using basic authentication the userid and password may be specified as system properties or in log4j2.component.properties as log4j2.configurationUserName=guest log4j2.configurationPassword=guest Note that Log4j currently does not support encrypting the password. If more extensive authentication is required an AuthorizationProvider can be implemented and defined in the log4j2.authorizationProvider system property or in log4j2.component.properties. TLS can be enabled by adding the following system properties or defining them in log4j2.component.properties
RequirementsThe Log4j 2 Spring Cloud Configuration integration has a dependency on Log4j 2 API, Log4j 2 Core, and Spring Cloud Configuration versions 2.0.3.RELEASE or 2.1.1.RELEASE or later versions it either release series. For more information, see Runtime Dependencies. |