log4j2 与 logback 条件判断

1. Log4j2

<AsyncRoot level="INFO">
    <appender-ref ref="FILEERROR"/>
    <appender-ref ref="FILEWARN"/>
    <appender-ref ref="FILEINFO"/>
    <appender-ref ref="FILEDEBUG"/>
    <appender-ref ref="CONSOLE"/>
    <appender-ref ref="GELF" if="${sys:spring.profiles.active:-dev} != 'dev'"/>
</AsyncRoot>

2. Logback

<if condition='property("spring.profiles.active").equals("dev")'>
    <then>
        <root level="INFO">
            <appender-ref ref="FILEERROR"/>
            <appender-ref ref="FILEWARN"/>
            <appender-ref ref="FILEINFO"/>
            <appender-ref ref="FILEDEBUG"/>
            <appender-ref ref="CONSOLE"/>
        </root>
    </then>
    <else>
        <root level="INFO">
            <appender-ref ref="FILEERROR"/>
            <appender-ref ref="FILEWARN"/>
            <appender-ref ref="FILEINFO"/>
            <appender-ref ref="FILEDEBUG"/>
            <appender-ref ref="CONSOLE"/>
            <appender-ref ref="GELF"/>
        </root>
    </else>
</if>

你可能感兴趣的:(java,log4j,logback)