Trouble Loading Nested Values from application.yaml in Logback for Kafka Appender Configuration

23 views Asked by At

I'm currently working with the latest version of Logback (1.4.14) in my microservice application and facing an issue with configuring a Kafka appender. My goal is to avoid hardcoding values for the Kafka appender configuration, especially for different environments like development, pre-production, and production.

In my application.yaml file, I have the Kafka configuration nested under kafka.consumer.topic like this:

kafka:
  consumer:
    topic: example.topic

I'm trying to load these nested values into my Logback configuration logback.xml file using the ${kafka.consumer.topic} syntax, but I'm encountering an issue where the topic value remains undefined.

Here's how I'm attempting to load the value in logback.xml:

<topic>${kafka.consumer.topic}</topic>

However, this approach doesn't seem to be working as expected, and the topic value remains undefined.

I've also tried using the <property resource=""> and <variable> tags in Logback's configuration, but I'm facing the same issue.

<property resource="application.yaml" />
<variable scope="context" file="application.yaml" />

Unfortunately, using application.properties instead of application.yaml is not an option due to company practices. PS logback version is 1.4.14, java 17, spring boot 3.1.5 Can someone please provide guidance on how to correctly load nested values from application.yaml into Logback's configuration?

Thank you!

0

There are 0 answers