1

I am using the Sentry log4j appender(version: 5.7.1) to send logged exceptions to Sentry. bellow is the log4j2.xml configuration.

 <?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" packages="org.apache.logging.log4j.core,io.sentry.log4j2">
  <Appenders>
    <Console name="Console" target="SYSTEM_OUT">
      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
    </Console>
    <Sentry name="Sentry"
            dsn="https://dsn" />
  </Appenders>
  <Loggers>
    <Root level="info">
      <AppenderRef ref="Sentry"/>
      <AppenderRef ref="Console"/>
    </Root>
  </Loggers>
</Configuration>

Now I need to add a specific environment in order to differentiate records based on the QA and Production environment. when I add environment="qa", it gives following error.

ERROR Sentry contains an invalid element or attribute "environment"

1 Answer 1

1

In Log4j2 integration, properties other than "dsn" can be configured either using:

  • environment variable: "SENTRY_ENVIRONMENT=qa"
  • system property "sentry.environment=qa"
  • sentry.properties file with content: environment=qa

Read more in docs: https://docs.sentry.io/platforms/java/configuration/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.