# Set Up User Feedback | Sentry for Log4j 2.x

The User Feedback feature allows you to collect user feedback from anywhere inside your application at any time, without needing an error event to occur first.

If you're using a self-hosted Sentry instance, you'll need to be on version 24.4.2 or higher in order to use the full functionality of the User Feedback feature. Lower versions may have limited functionality. Ensure you are using the Java SDK version 8.12.0 or above of the SDK to access the latest features.

## [User Feedback API](https://docs.sentry.io/.md#user-feedback-api)

The User Feedback API allows you to collect user feedback while using your own UI components.

Sentry can optionally pair the feedback with an event, giving you additional insight into issues. Sentry needs the `eventId` to be able to associate the user feedback to the corresponding event. For example, to get the `eventId`, you can use [`beforeSend`](https://docs.sentry.io/platforms/java/guides/log4j2/configuration/options.md#before-send)or the return value of the method capturing an event.

```java
import io.sentry.Sentry;
import io.sentry.protocol.Feedback;

Feedback feedback = new Feedback("I encountered a bug while using the app.");
feedback.setName("John Doe");
feedback.setContactEmail("john.doe@example.com");
// Optionally associate the feedback with an event
SentryId sentryId = Sentry.captureMessage("My message");
feedback.setAssociatedEventId(sentryId);

Sentry.captureFeedback(feedback);
```
