This module could let you integrate log4j2 with apollo easily.
You could create a namespace log42.xml
, then log4j2 will load the configuration from it.
There are several steps that need to do:
- Add
apollo-plugin-log4j2
dependency withlog4j2
dependency<dependency> <groupId>com.ctrip.framework.apollo</groupId> <artifactId>apollo-plugin-log4j2</artifactId> </dependency> <!-- log4j2 dependency --> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> </dependency>
- Create a new namespace
log4j2.xml
(namespace format must be XML) in your apollo application - Add system properties
apollo.log4j2.enabled
or set env variableAPOLLO_LOG4J2_ENABLED
when you run java application-Dapollo.log4j2.enabled=true
APOLLO_LOG4J2_ENABLED=true
- Now run the java application, then it could load log4j2 content from Apollo
By default, log4j2 will load the configuration from the classpath.
This module only affects when you set the system properties apollo.log4j2.enabled=true
or set the env variable APOLLO_LOG4J2_ENABLED =true
to enable it.