# Set Up Logs | Sentry for Log4j 2.x

##### Now in Beta

Sentry Logs is currently in Beta. Features are still in-progress and may have bugs. We recognize the irony. For any questions or feedback, you can reach us on [Discord](https://discord.gg/sentry) or [GitHub](https://github.com/getsentry/sentry/discussions/86804).

With Sentry Structured Logs, you can send text based log information from your applications to Sentry. Once in Sentry, these logs can be viewed alongside relevant errors, searched by text-string, or searched using their individual attributes.

## [Requirements](https://docs.sentry.io/platforms/java/guides/log4j2/logs.md#requirements)

Logs for Log4j2 are supported in Sentry Java SDK version `8.16.0` and above.

## [Setup](https://docs.sentry.io/platforms/java/guides/log4j2/logs.md#setup)

To enable logging, you need to configure the option in `sentry.properties` or when calling `Sentry.init`.

```properties
logs.enabled=true
```

You may also set `minimumLevel` in `log4j2.xml` to configure which log messages are sent to Sentry.

```xml
<Sentry
  name="Sentry"
  dsn="your DSN"
  minimumBreadcrumbLevel="DEBUG"
  minimumEventLevel="WARN"

  minimumLevel="DEBUG"

/>
```

## [Usage](https://docs.sentry.io/platforms/java/guides/log4j2/logs.md#usage)

Once the handler is configured with logging enabled, any logs at or above the `minimumLevel` will be sent to Sentry.

## [Integrations](https://docs.sentry.io/platforms/java/guides/log4j2/logs.md#integrations)

Available integrations:

* [Spring Boot using Logback](https://docs.sentry.io/platforms/java/guides/spring-boot/logging-frameworks.md)
* [Logback](https://docs.sentry.io/platforms/java/guides/logback/logs.md)
* [Log4j2](https://docs.sentry.io/platforms/java/guides/log4j2/logs.md)
* [JUL](https://docs.sentry.io/platforms/java/guides/jul/logs.md)

If there's an integration you would like to see, open a [new issue on GitHub](https://github.com/getsentry/sentry-java/issues/new/choose).

## [Options](https://docs.sentry.io/platforms/java/guides/log4j2/logs.md#options)

#### [beforeSendLog](https://docs.sentry.io/platforms/java/guides/log4j2/logs.md#beforesendlog)

To filter logs, or update them before they are sent to Sentry, you can use the `getLogs().beforeSend` option.

```java
import io.sentry.Sentry;

Sentry.init(options -> {
  options.setDsn("https://examplePublicKey@o0.ingest.sentry.io/0");

  options.getLogs().setBeforeSend((logEvent) -> {
    // Modify the event here:
    logEvent.setBody("new message body");
    return logEvent;
  });

});
```

The `beforeSend` function receives a log object, and should return the log object if you want it to be sent to Sentry, or `null` if you want to discard it.
