This should just be a quick question. I am wondering if this syntax would be correct.
Inside log4j.properties
log4j.rootLogger=${ROOT_LOGGER:INFO}, console
So what I'm trying to achieve is to have a ROOT_LOGGER env variable and if it's not present, fallback to INFO
. I know this works in .yaml
files, so just wondering if the same applies here.
Long time but Im going to put my found solution here.
we can add vars on properties like:
build.gragle dependencies
dependencies {
implementation "org.apache.logging.log4j:log4j-api:2.14.1"
implementation "org.apache.logging.log4j:log4j-core:2.14.1"
}
log4j2.properties
appender.consoledev.type=Console
appender.consoledev.name=CONSOLEDEV
appender.consoledev.layout.type=PatternLayout
appender.consoledev.layout.pattern=%d{HH:mm:ss.sss} %5p %20logger{36} : %msg%n
loggers=logapp
logger.logapp.name=${sys:logging.package:-com.test}
logger.logapp.level=${sys:logging.level:-DEBUG}
logger.logapp.additivity=false
logger.logapp.appenderRef.consoledev.ref=CONSOLEDEV
running jar with args
java -jar -Dlogging.level=INFO -Dlogging.package=com.test.MainClass test.jar
java -jar -Dlogging.level=INFO -Dlogging.package=com.test test.jar
java -jar -Dlogging.level=DEBUG -Dlogging.package=root test.jar
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.