-
-
Notifications
You must be signed in to change notification settings - Fork 468
Expand file tree
/
Copy pathMain.java
More file actions
39 lines (30 loc) · 1.22 KB
/
Main.java
File metadata and controls
39 lines (30 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package io.sentry.samples.jul;
import io.sentry.Sentry;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import org.slf4j.MDC;
public class Main {
private static final Logger LOGGER = Logger.getLogger(Main.class.getName());
public static void main(String[] args) throws Exception {
// instead of the following line you can also pass
// -Djava.util.logging.config.file=.../logging.properties to the
// java command
LogManager.getLogManager()
.readConfiguration(Main.class.getClassLoader().getResourceAsStream("logging.properties"));
LOGGER.config("Hello Sentry!");
// MDC parameters are converted to Sentry Event tags
MDC.put("userId", UUID.randomUUID().toString());
MDC.put("requestId", UUID.randomUUID().toString());
Sentry.addFeatureFlag("my-feature-flag", true);
LOGGER.warning("important warning");
// logging arguments are converted to Sentry Event parameters
LOGGER.log(Level.INFO, "User has made a purchase of product: %d", 445);
try {
throw new RuntimeException("Invalid productId=445");
} catch (Throwable e) {
LOGGER.log(Level.SEVERE, "Something went wrong", e);
}
}
}