Hey I need help with sentry and log4j2. Sentry works fine for me but when I want to use log4j2 no error is sent to sentry.
Otherwise sentry works fine without log4j2 can someone please help me please?
This is my example Code
public class Test {
private static final Logger logger = LogManager.getLogger(Test.class);
public static void main(String[] args) {
logger.error("test");
}
}
normal and simple class
This is my log4j2.xml
<?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="mydns"
minimumBreadcrumbLevel="DEBUG"
minimumEventLevel="WARN"
/>
</Appenders>
<Loggers>
<Root level="warn">
<AppenderRef ref="Sentry"/>
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
I got the log4j2.xml from the sentry documentation
This is my pom
<dependencies>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-log4j2</artifactId>
<version>4.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.13.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.0</version>
</dependency>
</dependencies>