프로그래밍언어/Java
log4j2 Property default 기본값 넣기
codinglog
2020. 7. 17. 15:32
<RollingFile name="RollingFile" fileName="${sys:fileHourName}" filePattern="${sys:fileHourPattern}">
이 Appender에 환경변수값을 바인딩할 수 있는 표현식 ${sys:key} 에서 환경변수에 그 값이 없으면 기본값으로 가지도록 하고자 할 때는
<properties>
<property name="fileHourName">local</property>
</properties>
<properties> 에 <property> 를 추가하면 된다.
표현식 내에서 직접 넣고 싶으면 ${sys:fileHourName:-하고싶은값} 형태로 선언하면 된다.
프로퍼티 내에 표현식이 있을 때도 마찬가지로 하면 된다.
<property name="systemLogLevel">INFO</property>
<property name="logLevel">${sys:systemLogLevel}</property>
http://logging.apache.org/log4j/2.x/manual/configuration.html#PropertySubstitution
반응형