μ€νλ§ νλ‘μ νΈ logback μ€μ μ€λ₯ (Could not find Janino library on the class path)
μ€νλ§ νλ‘μ νΈμμ logbackμ μ΄μ©νμ¬ νκ²½λ³λ‘ λ‘κ·Έ μ€μ μ λ€λ₯΄κ² ν λ
<if>, <elseif> λ±μ νκ·Έλ₯Ό μ΄μ©ν μ μλ μ€ μκ³ μλμ²λΌ μ€μ μ ν΄λ³΄μλ€.
<if condition="property('myproject.profile').equals('live')">
<logger name="com.myproject" level="debug">
<appender-ref ref="STDOUT"/>
</logger>
<logger name="org.springframework" level="WARN"/>
<root level="info"/>
</if>
<elseif condition="property('myproject.profile').equals('dev')">
<logger name="com.myproject" level="debug">
<appender-ref ref="STDOUT"/>
</logger>
<logger name="org.springframework" level="WARN"/>
<root level="info"/>
</elseif>
<else condition="property('myproject.profile').equals('local')">
<root level="debug">
<appender-ref ref="STDOUT" />
</root>
</else>
μ μ²λΌ μ€μ νλλ° μ± κΈ°λ μ μλμ²λΌ logbackμμ μλ¬λ‘κ·Έλ₯Ό μ°μλ€.
14:46:24,662 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
14:46:24,668 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - This appender no longer admits a layout as a sub-component, set an encoder instead.
14:46:24,668 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
14:46:24,668 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
14:46:24,673 |-ERROR in ch.qos.logback.core.joran.conditional.IfAction - Could not find Janino library on the class path. Skipping conditional processing.
14:46:24,673 |-ERROR in ch.qos.logback.core.joran.conditional.IfAction - See also http://logback.qos.ch/codes.html#ifJanino
14:46:24,673 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@31:64 - no applicable action for [logger], current ElementPath is [[configuration][if][logger]]
14:46:24,674 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@32:42 - no applicable action for [appender-ref], current ElementPath is [[configuration][if][logger][appender-ref]]
μμΈμ λͺ νν΄λ³΄μλ€. JaninoλΌλ λΌμ΄λΈλ¬λ¦¬κ° μμ΄μμλ€.
<if>, <elseif> λ±μ νκ·Έλ¬Έλ²μ Janino λΌμ΄λΈλ¬λ¦¬μμ ν΄μμ ν΄μ£Όλλ° ν΄λΉ λΌμ΄λΈλ¬λ¦¬κ° μμ΄μ logback μ€μ νμΌν΄μμ μ λλ‘ λͺ»ν μνμλ€.
κ·Έλμ νμ¬μΌμ κ°μ₯ μ΅μ λ²μ μΌλ‘ μμ‘΄μ±μ μΆκ°νλ€.
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
<version>3.0.14</version>
</dependency>
κ·Έλ°λ° λ μ€λ₯κ° λ¬λ€ γ γ
Failed to parse condition [property('myproject.profile').equals('live')] org.codehaus.commons.compiler.CompileException: Line 1, Column 45: Closing single quote missing
at org.codehaus.commons.compiler.CompileException: Line 1, Column 45: Closing single quote missing
쑰건μΌλ‘ μ€κ² νμ±μ€λ₯κ° λ¬λ¨λ€. κ·Έλμ 컨λμ μ μλμ²λΌ λ°κΎΈμλ€.
<if condition='property("myproject.profile").equals("local")'>
μλ°μ΄νμ νλ°μ΄νλ₯Ό λ°κΎΌκ±°λ€.
κ·Έλ¦¬κ³ if-else if - else λ₯Ό νκΈ°μν΄μ nested ifλ₯Ό μ¨μΌνλ€.
νμ§λ§ nested <if> λ₯Ό μ°κΈ°μ μμͺ½μΌλ‘ μΈλ΄νΈ λλ κ² λ§μμ Έμ κ°λ μ±μ΄ λ¨μ΄μ§λ€.
μ΄μ°¨νΌ 쑰건μ equalsλ‘ λΉκ΅νκ³ μμΌλ
κ²°κ³Όμ μΌλ‘ ifλ¬Έλ§ μ¨μ profileκ°μ λΉκ΅ν΄μ£Όμ΄λ if-elseifμ ν¨κ³Όλ λ³Ό μ μμΌλ―λ‘ μλμ²λΌ λ°κΏ¨λ€.
<if condition='property("myproject.profile").equals("live")'>
<then>
<logger name="com.myproject" level="debug">
<appender-ref ref="ELASTIC"/>
</logger>
<logger name="org.springframework" level="WARN"/>
<root level="info"/>
</then>
</if>
<if condition='property("myproject.profile").equals("dev")'>
<then>
<logger name="com.myproject" level="debug">
<appender-ref ref="ELASTIC"/>
</logger>
<logger name="org.springframework" level="WARN"/>
<root level="info"/>
</then>
</if>
<if condition='property("myproject.profile").equals("local")'>
<then>
<logger name="com.myproject" level="debug">
<appender-ref ref="STDOUT"/>
</logger>
<root level="info">
<appender-ref ref="STDOUT"/>
</root>
</then>
</if>
μ΄μ μ λμνλ€.