quarkiverse / quarkus-logging-logback

Quarkus Logback extension
Apache License 2.0
13 stars 13 forks source link

Logback Variable Substitution does not work as expected for <property #195

Open LeanderCoevoet opened 5 hours ago

LeanderCoevoet commented 5 hours ago

Hello,

I want to use the logback variable substitution feature. Unfortunately it does not work as expected.

Logback.xml

<?xml` version="1.0" encoding="UTF-8"?>
<configuration debug="true">

  <property scope="context" name="ENV" value="${logging.application.environment}" />

    ...
  <appender name="LogzioLogbackAppender" class="io.logz.logback.LogzioLogbackAppender">
    <token>LOGZIO_TOKEN</token>
    <logzioUrl>${logging.logzio.url}</logzioUrl>
    <additionalFields>env=${logging.application.environment}</additionalFields>
    <additionalFields>ENV=${ENV}</additionalFields>
  </appender>

  <root level="info">
    <appender-ref ref="Console"/>
    <if condition='!property("ENV").contains("dev")'>
      <then>
        <appender-ref ref="LogzioLogbackAppender"/>
      </then>
    </if>
  </root>

  <!-- Use shutdownHook so that we can close gracefully and finish the log drain -->
  <shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook"/>

</configuration>

When running I saw that the value was "logging.application.environment_IS_UNDEFINED". I would expect it would say "dev"like the other additional property.

LeanderCoevoet commented 5 hours ago

Looks like the problem is https://github.com/quarkiverse/quarkus-logging-logback/blob/main/impl/runtime/src/main/java/io/quarkiverse/logback/runtime/LogbackRecorder.java#L70 index in used instead of j