简体   繁体   中英

CompositeConfiguration in log4j2 using springboot

I am working in spring boot project and I stuck in an issue. Following is the problem.

I have two log4j2 configuration file. Log4j2-1.yml and Log4j2-2.yml. Log4j2-1.yml consist the common configuration to avoid repetition duplicate configuration while Log4j2-2.yml consists application specific log config. I need to use these two log4j2 configuration in my application at same time. Please help me to configure these files in my application.\

I tried log4j2.configurationFile also but could not succeed.

Spring Boot has a custom logging configuration process that occurs just after the Log4j2 automatic configuration (its exact logic is in Log4j2LoggingSystem and is documented in Core Features ). You can analyze the process by setting -Dlog4j2.debug=true .

To create a composite configuration you need to use two Spring Boot properties (cf. core properties ):

logging.config=classpath:Log4j2-1.yml
logging.log4j2.config.override=classpath:Log4j2-2.yml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM