Issue
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"
Solution
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/
Answered By - Maciej Walkowiak
Answer Checked By - Marie Seifert (JavaFixing Admin)