Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log4j2 Environment Lookup not substituted correctly #389

Open
raminqaf opened this issue Nov 16, 2023 · 1 comment
Open

Log4j2 Environment Lookup not substituted correctly #389

raminqaf opened this issue Nov 16, 2023 · 1 comment
Labels
component/generator Related to the generation of pipeline.yaml type/bug Something isn't working

Comments

@raminqaf
Copy link
Contributor

The Environment Lookup in Log4j2 cannot be processed correctly by KPOps. If we define the log4jConfig in the kafka-app like that:

kafka-app:
  app:
    streams:
      brokers: "${brokers}"
      schemaRegistryUrl: http://schema-registry:8081
    log4jConfig: |
      <?xml version="1.0" encoding="UTF-8"?>
      <Configuration>
          <Appenders>
              <Console name="Console" target="SYSTEM_OUT">
                  <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n"/>
              </Console>
          </Appenders>
          <Loggers>
              <Logger additivity="false" level="$${env:STREAMS_LOG_LEVEL:-info}" name="com.bakdata">
                  <AppenderRef ref="Console"/>
              </Logger>
              <Root level="info">
                  <AppenderRef ref="Console"/>
              </Root>
          </Loggers>
      </Configuration>
    labels:
      pipeline: ${pipeline_name_0}

And then use the KPOps generate ... --template the output of the ConfigMap (where the log config lives) looks like this:

# Source: streams-app/templates/log4j-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: my-streams-app-log4j-configmap
data:
  log4j2.xml: |
    <?xml version="1.0" encoding="UTF-8"?>
    <Configuration>
        <Appenders>
            <Console name="Console" target="SYSTEM_OUT">
                <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n"/>
            </Console>
        </Appenders>
        <Loggers>
            <Logger additivity="false" level="${env:STREAMS_LOG_LEVEL:-info}" name="com.bakdata">
                <AppenderRef ref="Console"/>
            </Logger>
            <Root level="info">
                <AppenderRef ref="Console"/>
            </Root>
        </Loggers>
    </Configuration>
@raminqaf raminqaf added type/bug Something isn't working component/generator Related to the generation of pipeline.yaml labels Nov 16, 2023
@sujuka99
Copy link
Contributor

That is because string.Template.substitute sees $$ as an escaped $, hence it removes 1 of the dollar signs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/generator Related to the generation of pipeline.yaml type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants